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
142 stars 13 forks source link

tools/inference.py #28

Closed PolarisFTL closed 2 months ago

PolarisFTL commented 2 months ago

Hello, I've encountered the following error while reasoning, and I can't solve it even if I try to debug it, so I'd like to ask if you have a solution for it:

load checkpoint from local path: work_dirs/finetune_mask-rcnn_1x_coco_lr3e-2_wd5e-5/latest.pth load checkpoint from local path: work_dirs/selfsup_mask-rcnn/epoch_6.pth /home/lzb/miniconda3/envs/Align/lib/python3.9/site-packages/mmdet/datasets/utils.py:66: UserWarning: "ImageToTensor" pipeline is replaced by "DefaultFormatBundle" for batch inference. It is recommended to manually replace it in the test data pipeline in your config file. warnings.warn( Traceback (most recent call last): File "/home/lzb/ftl/AlignDet/inference.py", line 19, in result = inference_detector(random_model, img) File "/home/lzb/miniconda3/envs/Align/lib/python3.9/site-packages/mmdet/apis/inference.py", line 152, in inference_detector results = model(return_loss=False, rescale=True, *data) File "/home/lzb/miniconda3/envs/Align/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl return forward_call(input, kwargs) TypeError: forward() missing 1 required positional argument: 'data'**

liming-ai commented 2 months ago

Hello, I've encountered the following error while reasoning, and I can't solve it even if I try to debug it, so I'd like to ask if you have a solution for it:

load checkpoint from local path: work_dirs/finetune_mask-rcnn_1x_coco_lr3e-2_wd5e-5/latest.pth load checkpoint from local path: work_dirs/selfsup_mask-rcnn/epoch_6.pth /home/lzb/miniconda3/envs/Align/lib/python3.9/site-packages/mmdet/datasets/utils.py:66: UserWarning: "ImageToTensor" pipeline is replaced by "DefaultFormatBundle" for batch inference. It is recommended to manually replace it in the test data pipeline in your config file. warnings.warn( Traceback (most recent call last): File "/home/lzb/ftl/AlignDet/inference.py", line 19, in result = inference_detector(random_model, img) File "/home/lzb/miniconda3/envs/Align/lib/python3.9/site-packages/mmdet/apis/inference.py", line 152, in inference_detector results = model(return_loss=False, rescale=True, *data) File "/home/lzb/miniconda3/envs/Align/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl return forward_call(input, kwargs) TypeError: forward() missing 1 required positional argument: 'data'**

It seems that your mmdetection version is wrong. Can you install the environment according to the instructions in README and try again?

PolarisFTL commented 2 months ago

Thanks for your reply, I found that the inference code can generate the results of the final model but not the results of the self-supervised pre-trained model which is the sup_model related code of your code

liming-ai commented 2 months ago

Thanks for your reply, I found that the inference code can generate the results of the final model but not the results of the self-supervised pre-trained model which is the sup_model related code of your code

Your understanding is correct. The inference code here is to visualize the detection box of the fine-tuned model, and cannot be used to visualize the pre-trained bbox.

If you want to visualize the unsupervised bbox (pseudo label) of selective search, you can refer to this code

If you want to visualize the bbox output of a self-supervised trained model, only the Mask/Faster R-CNN model that uses RPN can do this. You can write your own code to visualize the output of the RPN module.

PolarisFTL commented 2 months ago

Thanks a lot!