IDEA-Research / DINO

[ICLR 2023] Official implementation of the paper "DINO: DETR with Improved DeNoising Anchor Boxes for End-to-End Object Detection"
Apache License 2.0
2.15k stars 232 forks source link

changing the topk value of a trained model is decreasing the models performance. #146

Open ajay1234567899 opened 1 year ago

ajay1234567899 commented 1 year ago

Hello sir,

I tried to run your model on a single sample image. When the topk value = 900, the model detects most of the objects( with confidence > 0.5), but when I reduce the topk value to 100, more than 80% of the detections get vanish (those objects which went missing will be present at confidence < 0.4).

I am not able to understand the reason why this is happening. I would greatly appreciate your reply.

Modifications done are : In this file https://github.com/IDEA-Research/DINO/blob/main/models/dino/deformable_transformer.py

I have changed line 341 from topk = self.num_queries --------------> to topk = 100

and

Line 352 from tgt_ = self.tgt_embed.weight[:, None, :].repeat(1, bs, 1).transpose(0, 1) # nq, bs, dmodel ----------------------> to tgt = self.tgt_embed.weight[:topk, None, :].repeat(1, bs, 1).transpose(0, 1) # nq, bs, d_model

HaoZhang534 commented 1 year ago

@ajay1234567899 I recommend visualizing objects with a confidence score>0.25 so that most objects will appear. Also, if you want to modify the number of queries, you should set num_queries=100.