-
Notifications
You must be signed in to change notification settings - Fork 414
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Search before asking
- I have searched the RF-DETR issues and found no similar bug report.
Bug
I have Finetuned my RFDETRSmall Model using the method below:
import torch
torch.cuda.set_device(1)
model = RFDETRSmall(num_classes=7,resolution=1792)
model.train(
dataset_dir="/reshape_1792/roboflow_dataset",
epochs=100,
batch_size=8,
grad_accum_steps=1,
output_dir="reshape_1792/roboflow_output_updated",
early_stopping=True,
weight_decay=1e-4
)
Note, i have also tried this with pretrained_weights=False.
Issue i am encountering is that my model even after training is not saving the num_classes properly and instead has 90 unique classes. When it ry to evaluate and get my metrics i get 0s because classes are not aligned with my dataset. Any idea what could be causing this or may be a potential fix? Here is the output of my evaluation below:
Number of classes in ds: 7
Class names: ['ADA pads', 'Guard rail', 'Traffic lights', 'Fire hydrant', 'Drain', 'Traffic cone', 'Garbage bin']
Unique class IDs in detections: {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90}
Max class ID: 90
Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.000
Average Precision (AP) @[ IoU=0.50 | area= all | maxDets=100 ] = 0.000
Average Precision (AP) @[ IoU=0.75 | area= all | maxDets=100 ] = 0.000
Average Precision (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.000
Average Precision (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.000
Average Precision (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.000
Environment
- RF-DETR 1.3.0
Minimal Reproducible Example
from PIL import Image
from rfdetr import RFDETRSmall
from tqdm import tqdm
import supervision as sv
from supervision.metrics import MeanAveragePrecision, Precision
model = RFDETRSmall(num_classes=7, pretrained_weights='/reshape_1792/roboflow_output_updated/checkpoint_best_total.pth', resolution=1792)
# model.optimize_for_inference()
ds = sv.DetectionDataset.from_coco(
images_directory_path="/reshape_1792/roboflow_dataset/test/",
annotations_path="/reshape_1792/roboflow_dataset/test/_annotations.coco.json",
)
targets = []
predictions = []
for path, frame, annotations in tqdm(ds):
frame = Image.open(path)
detections = model.predict(frame.copy(),threshold=0.3)
targets.append(annotations)
predictions.append(detections)
print("Number of classes in ds:", len(ds.classes))
print("Class names:", ds.classes)
print("Unique class IDs in detections:", set(detections.class_id))
print("Max class ID:", max(detections.class_id) if len(detections.class_id) > 0 else "None")
map_metric = MeanAveragePrecision()
map_result = map_metric.update(predictions, targets).compute()
print(map_result)
Additional
No response
Are you willing to submit a PR?
- Yes, I'd like to help by submitting a PR!
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working