shaunyuan22 / CFINet

The official implementation for ICCV'23 paper "Small Object Detection via Coarse-to-fine Proposal Generation and Imitation Learning"
Apache License 2.0
123 stars 6 forks source link

[Reimplementation] of CFINet on AITOD #34

Closed OE-jimvanoosten closed 1 month ago

OE-jimvanoosten commented 2 months ago

Prerequisite

💬 Describe the reimplementation questions

Hi there, I am trying to train CFINet on AITOD, and I am getting an error which I cannot seem to fix. In _feature_imitation_roihead.py there is a function called _contrastforward, and in there, there is this line:

sim_logits_max, _ = torch.max(sim_logits, dim=1, keepdim=True)

This gives me the following error:

Traceback (most recent call last): File "tools/train.py", line 237, in <module> main() File "tools/train.py", line 233, in main meta=meta) File "/notebooks/mmdet-aitod/mmdet-nwdrka/mmdet/apis/train.py", line 244, in train_detector runner.run(data_loaders, cfg.workflow) File "/notebooks/venv/lib/python3.7/site-packages/mmcv/runner/epoch_based_runner.py", line 127, in run epoch_runner(data_loaders[i], **kwargs) File "/notebooks/venv/lib/python3.7/site-packages/mmcv/runner/epoch_based_runner.py", line 50, in train self.run_iter(data_batch, train_mode=True, **kwargs) File "/notebooks/venv/lib/python3.7/site-packages/mmcv/runner/epoch_based_runner.py", line 30, in run_iter **kwargs) File "/notebooks/venv/lib/python3.7/site-packages/mmcv/parallel/data_parallel.py", line 75, in train_step return self.module.train_step(*inputs[0], **kwargs[0]) File "/notebooks/mmdet-aitod/mmdet-nwdrka/mmdet/models/detectors/base.py", line 248, in train_step losses = self(**data) File "/notebooks/venv/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1110, in _call_impl return forward_call(*input, **kwargs) File "/notebooks/venv/lib/python3.7/site-packages/mmcv/runner/fp16_utils.py", line 140, in new_func output = old_func(*new_args, **new_kwargs) File "/notebooks/mmdet-aitod/mmdet-nwdrka/mmdet/models/detectors/base.py", line 172, in forward return self.forward_train(img, img_metas, **kwargs) File "/notebooks/mmdet-aitod/mmdet-nwdrka/mmdet/models/detectors/two_stage.py", line 150, in forward_train **kwargs) File "/notebooks/mmdet-aitod/mmdet-nwdrka/mmdet/models/roi_heads/feature_imitation_roi_head.py", line 206, in forward_train gt_bboxes, gt_labels, img_metas) File "/notebooks/mmdet-aitod/mmdet-nwdrka/mmdet/models/roi_heads/feature_imitation_roi_head.py", line 417, in _bbox_forward_train pos_signs, iq_loss_weights) File "/notebooks/mmdet-aitod/mmdet-nwdrka/mmdet/models/roi_heads/feature_imitation_roi_head.py", line 469, in contrast_forward sim_logits_max, _ = torch.max(sim_logits, dim=1, keepdim=True) IndexError: max(): Expected reduction dim 1 to have non-zero size.

Could this have something to do with the classes being different on the AITOD and the SODA set. Let me know. Thanks a lot!

Environment

Same dependencies as in the repo.

Expected results

No response

Additional information

No response

shaunyuan22 commented 2 months ago

you may need to check are there any elments in dim 1 of sim_logits, and moreover, and I don't think the difference in dataset categories would cause such an error, but we need to debug further to be sure.

OE-jimvanoosten commented 2 months ago

I found out that this error occurs only when the RPN does not come up with any region proposals. This way, the roi_head receives empty tensors with which I cannot do any calculations.

OE-jimvanoosten commented 2 months ago

Screenshot from 2024-07-08 12-05-56

OE-jimvanoosten commented 2 months ago

This image, for instance, does not yield any regions of interest.