liming-ai / AlignDet

Official code for ICCV 2023 Paper: AlignDet: Aligning Pre-training and Fine-tuning in Object Detection.
https://liming-ai.github.io/AlignDet/
Apache License 2.0
140 stars 14 forks source link

AttributeError: SelfSupDeformableDETR: SelfSupDeformableDETRHead: 'ContrastiveLoss' object has no attribute 'use_sigmoid' #4

Closed smarengin closed 1 year ago

smarengin commented 1 year ago

When I use the configuration "configs selfsup doormaple_detr. py" for training, some errors occur: Traceback (most recent call last): File "/opt/conda/lib/python3.7/site-packages/mmcv/utils/registry.py", line 69, in build_from_cfg return obj_cls(*args) File "/nas/xxxx/mmdet/aligndet/code/AlignDet/models/detectors/selfsup_detector.py", line 33, in init self.online_backbone = build_detector(backbone) File "/opt/conda/lib/python3.7/site-packages/mmdet/models/builder.py", line 59, in build_detector cfg, default_args=dict(train_cfg=train_cfg, test_cfg=test_cfg)) File "/opt/conda/lib/python3.7/site-packages/mmcv/utils/registry.py", line 237, in build return self.build_func(args, **kwargs, registry=self) File "/opt/conda/lib/python3.7/site-packages/mmcv/cnn/builder.py", line 27, in build_model_from_cfg return build_from_cfg(cfg, registry, default_args) File "/opt/conda/lib/python3.7/site-packages/mmcv/utils/registry.py", line 72, in build_from_cfg raise type(e)(f'{obj_cls.name}: {e}') AttributeError: SelfSupDeformableDETR: SelfSupDeformableDETRHead: 'ContrastiveLoss' object has no attribute 'use_sigmoid'

please help me, thank you!

liming-ai commented 1 year ago

This should be a bug caused when I made the open-source code. Unfortunately, I don't have GPU resources for debugging right now. I will fix this problem as soon as possible (about two weeks).

Also, this should be a minor bug, I would appreciate it if you could create a PR to fix it.

Finally, if you can attach the complete running command and complete error log, it will be more helpful for our communication and help others better

smarengin commented 1 year ago

I really want to fix it, but I wonder when you train selfsup_deformable_detr, the loss_cls is ContrastiveLoss like fcos or CrossEntropyLoss like detr?the latter? If loss_cls is CrossEntropyLoss, I also need the file 'train2017_ratio3size0008@0.5_cluster-id-as-class.json', is that true? It's a really nice work, but when used in detr, it not so cute (a little complicated) beacause it need to do cluster using supervised pre-trained backbones.

liming-ai commented 1 year ago

I really want to fix it, but I wonder when you train selfsup_deformable_detr, the loss_cls is ContrastiveLoss like fcos or CrossEntropyLoss like detr?the latter? If loss_cls is CrossEntropyLoss, I also need the file 'train2017_ratio3size0008@0.5_cluster-id-as-class.json', is that true? It's a really nice work, but when used in detr, it not so cute (a little complicated) beacause it need to do cluster using supervised pre-trained backbones.

You can refer to DETR pre-training config, the training loss is combined with cross-entropy loss and contrastive loss. We admit that DETR-like methods do need this specific operation since the final loss should be aligned with the Hungarian Algorithm, where the bipartite matching needs class information, which is designed by DETR itself.

It doesn't look elegant and neat when we pre-train DETR, that's the truth, but we show better performance than other more complicated methods (e.g., UP-DETR) with a simple cluster-based trick.

The backbone can be either supervised pre-trained or self-supervised pre-trained, we also provide the checkpoints for SwAV backbone (a self-supervised backbone) for DETR pre-training and fine-tuning. For the box-feature clustering, we can use both supervised or self-supervised backbones, we use the supervised backbone because it is more straightforward.

How to design a more simple and elegant pre-training for DETR is indeed an open question, and I am very happy to discuss it with you.

smarengin commented 1 year ago

thanks for your reply. I really like to find good pre-train method for DETR series for it's the SOTA method in detection.

smarengin commented 1 year ago

thanks your kindly reply

liming-ai commented 1 year ago

thanks for your reply. I really like to find good pre-train method for DETR series for it's the SOTA method in detection.

Good luck and wish you success.

smarengin commented 1 year ago

I'm just the finder, you're the creator of good methods, so I really wish you success. :)