Skip to content

RF-DETR not detecting more than 300 objects #203

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
emerson-w opened this issue May 8, 2025 · 3 comments
Open

RF-DETR not detecting more than 300 objects #203

emerson-w opened this issue May 8, 2025 · 3 comments

Comments

@emerson-w
Copy link

I am installing RFDETR directly from the source using:
pip install git+https://github.com/roboflow/rf-detr.git

And training like so:
model = RFDETRBase()
model.train(
dataset_dir='...',
num_queries = 700,
num_select = 700
)

I'm getting this runtime error.

RuntimeError Traceback (most recent call last)
in <cell line: 0>()
18 model = RFDETRBase()
19
---> 20 model.train(
21 dataset_dir='/content/drive/MyDrive/RMMC_CAN_ds_v3/images',
22 num_queries = 700,

7 frames
/usr/local/lib/python3.11/dist-packages/rfdetr/models/lwdetr.py in forward(self, outputs, target_sizes)
552
553 prob = out_logits.sigmoid()
--> 554 topk_values, topk_indexes = torch.topk(prob.view(out_logits.shape[0], -1), self.num_select, dim=1)
555 scores = topk_values
556 topk_boxes = topk_indexes // out_logits.shape[2]

RuntimeError: selected index k out of range

Is it possible to train RF-DETR to detect more than 300 images? How can I do this?

@isaacrob-roboflow
Copy link
Collaborator

unfortunately, using the pretrained checkpoint you won't be able to detect more than 300 objects in a given image. you'd have to train from scratch.

can you say a bit more about your use case?

@emerson-w
Copy link
Author

I am now training from scratch like so:
model = RFDETRBase(
pretrain_weights=None,
num_classes=1,
num_queries =700,
num_select = 700
)

model.train(
dataset_dir= '...',
num_queries = 700,
num_select = 700,
epochs=100,
...
)

detections = model.predict(image, threshold=0.1, num_select = 700, num_queries = 700)

But there are still only 300 detections. Is it possible for RF-DETR to predict more than 300 objects?

My use case is counting the number of small objects in an image. These objects are all similar (num_classes = 1) and the training data supports this large number. I would like to be able to identify more than 300 objects without splitting up the image.

@isaacrob-roboflow
Copy link
Collaborator

that is likely a bug :) probably the num_select argument isn't getting propagated correctly .. are you comfortable submitting a PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants