CoolFace
Modelpublic

MohamedKhayat/fruit-detector-deformable-detr

sourceHugging Faceapache-2.0updated 8mo agoView on Hugging Face
0likes19downloads
Model Card

Fruit Detector - defor_detr

This model is a fine-tuned version of SenseTime/deformable-detr for fruit and vegetable detection.

Model Details

  • —Base Model: SenseTime/deformable-detr
  • —Architecture: defor_detr
  • —Task: Object Detection
  • —mAP@50:95 Score: 0.5961
  • —Input Size: 640x640

Classes

The model detects the following 12 fruit/vegetable classes:

IDClass
0Apple
1Cherry
2Figs
3Olive
4Pomegranate
5Orange
6Rockmelon
7Strawberry
8Potato
9Tomato
10Watermelon
11Bell-pepper

Usage

python
from transformers import AutoImageProcessor, AutoModelForObjectDetection
from PIL import Image
import torch

# Load model and processor
processor = AutoImageProcessor.from_pretrained("MohamedKhayat/fruit-detector-deformable-detr")
model = AutoModelForObjectDetection.from_pretrained("MohamedKhayat/fruit-detector-deformable-detr")

# Load and process image
image = Image.open("fruit_image.jpg")
inputs = processor(images=image, return_tensors="pt")

# Run inference
with torch.no_grad():
    outputs = model(**inputs)

# Post-process results
target_sizes = torch.tensor([[image.height, image.width]])
results = processor.post_process_object_detection(
    outputs, 
    threshold=0.5, 
    target_sizes=target_sizes
)[0]

for score, label, box in zip(results["scores"], results["labels"], results["boxes"]):
    box = box.tolist()
    print(f"Detected {model.config.id2label[label.item()]} with confidence {score:.2f} at {box}")

Training

This model was trained on a custom fruit detection dataset.

Training Repository: transformers-for-fruit-object-detection-internship

License

Apache 2.0