dddzg / up-detr

[TPAMI 2022 & CVPR2021 Oral] UP-DETR: Unsupervised Pre-training for Object Detection with Transformers
Apache License 2.0
476 stars 71 forks source link

num_classes #23

Closed rgbd-zml closed 2 years ago

rgbd-zml commented 2 years ago

Hi, why did you set the number of categories to 2 in the code. Can I set it to 1 or any integer in pre-train stage? Any advice is greatly appreciated.

if args.dataset_file=="ImageNet": num_classes = 2

dddzg commented 2 years ago

I think you are right. But, if you set num_classes to 1 you should change https://github.com/dddzg/up-detr/blob/be066dfca5e8f1f35a4331490e8239b579bbf497/datasets/selfdet.py#L73 this line to 0. Because, the last class is designed for no-object category.

rgbd-zml commented 2 years ago

I think you are right. But, if you set num_classes to 1 you should change

https://github.com/dddzg/up-detr/blob/be066dfca5e8f1f35a4331490e8239b579bbf497/datasets/selfdet.py#L73

this line to 0. Because, the last class is designed for no-object category.

Thanks for your reply! If the num_classes is set to 1, this means that the label-0 represents the object class and the label-1 represents the non-object category in the classification cost?

dddzg commented 2 years ago

Yes. So, in our code, label-0 is never used.

rgbd-zml commented 2 years ago

Yes. So, in our code, label-0 is never used.

Hi, I have also a confusion about the paper. There is a explanation in up-detr paper:

up-detr-paper

In this paper , label-1 represents the object category(matching). There are some differences between the code and the paper. I'm not sure when num_classes is set to 1, which one of label-0 and label-1 represents object category(matching)?

dddzg commented 2 years ago

I am sorry for the inconsistency. In our paper, 0 represents no-obj, 1 represents obj. In our code, 1 represents obj, 2 represents no-obj. (0 is nerver used, and there is 3 class num in total) https://github.com/dddzg/up-detr/blob/be066dfca5e8f1f35a4331490e8239b579bbf497/models/detr.py#L40

Check here for the loss calculation. https://github.com/dddzg/up-detr/blob/be066dfca5e8f1f35a4331490e8239b579bbf497/models/detr.py#L124-L126

If you set num classes to 1, 0 represents obj, 1 represents no-obj.

The last class always represents the no-obj in our code.

rgbd-zml commented 2 years ago

I get it! Thank you very much!