yeliudev / ConsNet

🚴‍♂️ ConsNet: Learning Consistency Graph for Zero-Shot Human-Object Interaction Detection (MM 2020)
https://arxiv.org/abs/2008.06254
GNU General Public License v3.0
33 stars 2 forks source link

load_checkpoint(model, checkpoint, map_location='cpu') NameError: name 'load_checkpoint' is not defined #2

Closed monacv closed 3 years ago

monacv commented 3 years ago

thanks a lot for great documentation. got an error in this step Screenshot from 2021-04-08 03-19-35

(consnet) mona@goku:~/research/code/ConsNet$ python tools/build_dataset.py --checkpoint checkpoints/
Traceback (most recent call last):
  File "tools/build_dataset.py", line 280, in <module>
    main()
  File "tools/build_dataset.py", line 259, in main
    model = build_detector(cfg.model, args.checkpoint)
  File "/home/mona/venv/consnet/lib/python3.8/site-packages/consnet/models/builder.py", line 50, in build_detector
    load_checkpoint(model, checkpoint, map_location='cpu')
NameError: name 'load_checkpoint' is not defined
yeliudev commented 3 years ago

It seems that the dependencies of full version are not installed correctly. Did you install consnet from PyPI? If so, please uninstall it and re-install it from source following this part. The PyPI version is only designed for HICO-DET APIs but not for training or testing the models.

yeliudev commented 3 years ago

Also, <path-to-checkpoint> should be a complete path to the object detetor's .pth file, e.g. checkpoints/faster_rcnn_r50_fpn_3x_coco-26df6f6b.pth.

yeliudev commented 3 years ago

Closing this issue due to lack of activity. Please feel free to re-open it if you have any further questions.

hannajiang commented 2 years ago

Hi, I also meet this problem, and I install consnet from source. When I move code from nncore.engine import load_checkpoint, set_random_seed in models/builder.py from try except module, this problem will be solved; but I meet another problem, image

yeliudev commented 2 years ago

May I ask that which pytorch, mmdet and nncore version are you using?

hannajiang commented 2 years ago

consnet 1.0.5 /home/jh/code/CosNet torch 1.8.1 mmdet 2.11.0 nncore 0.2.6

yeliudev commented 2 years ago

nncore 0.2.6 is not tested for this repo, the version we used is 0.2.4. Also, if you meet some problem when from nncore.engine import load_checkpoint, set_random_seed is in the try except module, it seems that there's something wrong in your mmcv/mmdet.

PradKalkar commented 1 year ago

Hi. Thanks for the docs. I am getting the same error as faced by two others - NameError: name 'load_checkpoint' is not defined. I did install consnet from the source and didn't do pip install consnet. Also, I checked the versions of pytorch, mmdet and nncore - they are 1.8.1+cu102, 2.11.0 and 0.2.4 respectively. Could you please help?

yeliudev commented 1 year ago

Hi. Thanks for the docs. I am getting the same error as faced by two others - NameError: name 'load_checkpoint' is not defined. I did install consnet from the source and didn't do pip install consnet. Also, I checked the versions of pytorch, mmdet and nncore - they are 1.8.1+cu102, 2.11.0 and 0.2.4 respectively. Could you please help?

Thanks for your feedback. May I ask that did you install consnet from source using pip install -e .[full] ranther than pip install -e .? You may also try to modify the code here by moving the imports out of try...except to see which line raises the error.

PradKalkar commented 1 year ago

Hi. Thank you @yeliudev for the reply. I installed consnet from the source using the first command you mentioned - pip install -e .[full] I tried removing the try-except block, but I was facing another error. I will send here the screenshot of the error in some time, as currently I am not having access to that computer.

PradKalkar commented 1 year ago

ModuleNotFoundError: No module named 'mmcv._ext' This is the error which I am facing after removing the try except block. PFA the traceback below.

image image

PradKalkar commented 1 year ago

Also @yeliudev may I ask that what is the object detection mAP (not the HOI mAP using the complete model) on the HICO-DET test set of the two object detectors which you used - first one pretrained on COCO and the other one finetuned on HICO-DET?

yeliudev commented 1 year ago

ModuleNotFoundError: No module named 'mmcv._ext' This is the error which I am facing after removing the try except block. PFA the traceback below.

image image

This means that you are using mmcv instead of mmcv-full. So that the CUDA extensions are not compiled. You may try to re-install this package.

yeliudev commented 1 year ago

Also @yeliudev may I ask that what is the object detection mAP (not the HOI mAP using the complete model) on the HICO-DET test set of the two object detectors which you used - first one pretrained on COCO and the other one finetuned on HICO-DET?

I'm not pretty sure since this project was finished years ago. I remember that the mAP of COCO detector was about 13, and the HICO-DET finetuned one shall be about 20.

PradKalkar commented 1 year ago

Also @yeliudev may I ask that what is the object detection mAP (not the HOI mAP using the complete model) on the HICO-DET test set of the two object detectors which you used - first one pretrained on COCO and the other one finetuned on HICO-DET?

I'm not pretty sure since this project was finished years ago. I remember that the mAP of COCO detector was about 13, and the HICO-DET finetuned one shall be about 20.

Thanks for your response @yeliudev.

PradKalkar commented 1 year ago

ModuleNotFoundError: No module named 'mmcv._ext' This is the error which I am facing after removing the try except block. PFA the traceback below. image image

This means that you are using mmcv instead of mmcv-full. So that the CUDA extensions are not compiled. You may try to re-install this package.

But, I installed it using the pip install command given in your docs. Also, I tried to uninstall mmcv but upon doing that it says mmcv not found, which means that mmcv-full was installed. Would you please help? Also, what version of cudatoolkit-dev did you use in your conda environment? Here https://anaconda.org/conda-forge/cudatoolkit-dev/files?page=2 it shows that cudatoolkit-dev version 10.2 doesn't exists.

yeliudev commented 1 year ago

There are two versions of mmcv, one is called mmcv and the other shall be mmcv-full. You may try to manually install it by using pip install mmcv-full and see if the CUDA extensions are compiled correctly. We did not use cudatoolkit-dev in our env. We installed CUDA from scratch in our system.

PradKalkar commented 1 year ago

Thanks for the reply. Would you please check and share the exact version of your mmcv-full?

yeliudev commented 1 year ago

1.3.8

PradKalkar commented 1 year ago

Thanks for sharing the version. I will check by installing this version on the system. Also, will the CUDA version matter? I don't have 10.2 in my system. Is the issue coming because of that?

yeliudev commented 1 year ago

I don't think the CUDA version matters. Compiling mmcv-full using your own CUDA shall be fine. Please feel free to leave a message here if you meet any other problems.

PradKalkar commented 1 year ago

Would you please clarify the meaning of "compiling" mmcv-full using your own CUDA? Is compiling a separate step to be done after installing mmcv-full? If yes, would you please share the command for doing so.

yeliudev commented 1 year ago

Simply running pip install mmcv-full==1.3.8 should compile it automatically. Please be check that if there is any error during the installation.

PradKalkar commented 1 year ago

Thanks for your quick responses @yeliudev.

PradKalkar commented 1 year ago

Hi. I was able to resolve the mmcv error. But, now I am encountering another error. I installed the packages as follows -

  1. pip install torch==1.8.1+cu111 torchvision==0.9.1+cu111 torchaudio==0.8.1 -f https://download.pytorch.org/whl/torch_stable.html
  2. pip install -U openmim mim install mmcv-full==1.3.8 pip install mmdet==2.11.0
  3. pip install nncore==0.2.4

With the above 3 steps, the command of python tools/build_dataset.py started executing correctly and the hdf5 files were making up (i.e. the detection step and extraction of features). But allennlp wasn't installed. So, once I understood that mmcv is working fine, I interrupted the above execution. Then, I installed allenlp using -

  1. pip install allennlp==2.2.0

After this, I again ran the same command (python tools/build_dataset.py), but it errored out. Attaching the traceback below. Will the above command (python tools/build_dataset.py) work even without installing allennlp? Or will it require allennlp to be installed? I assume that build_graph function in the file won't work without allennlp. Is it right?

image image

yeliudev commented 1 year ago

It seems that the version of package transformers is not correct. Could you install transformers==0.11 and try it again?

PradKalkar commented 1 year ago

It seems that the version of package transformers is not correct. Could you install transformers==0.11 and try it again?

Getting this when trying to install it. :( image