Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImportError: Failed to import projects.<MODEL_NAME>.<model> #11082

Closed
charisoudis opened this issue Oct 24, 2023 · 5 comments
Closed

ImportError: Failed to import projects.<MODEL_NAME>.<model> #11082

charisoudis opened this issue Oct 24, 2023 · 5 comments
Assignees

Comments

@charisoudis
Copy link

charisoudis commented Oct 24, 2023

I cannot instantiate a custom model, Co-DETR given the weights.

After searching, it seems that there is a package named "projects" which prevents python from searching into the mmdetection directory (it is in the PYTHONPATH).

>>> from mmdet.apis import DetInferencer
>>> DetInferencer(weights='/workspace/out/checkpoints/co-detr/co_dino_5scale_r50_lsj_8xb2_1x_coco-69a72d67.pth')
>>> ...
>>> ImportError: Failed to import custom modules from {'allow_failed_imports': False, 'imports': ['projects.CO-DETR.codetr']}, the current sys.path is: 
    
    /mmdetection
    /workspace
    /opt/conda/lib/python310.zip
    /opt/conda/lib/python3.10
    /opt/conda/lib/python3.10/lib-dynload
    /opt/conda/lib/python3.10/site-packages
    /opt/conda/lib/python3.10/site-packages/smplx-0.1.28-py3.10.egg
    /tmp/tmp1_v1g0zy
You should set `PYTHONPATH` to make `sys.path` include the directory which contains your custom module
>>>
>>>
>>> import projects
>>> projects.__file__
'/opt/conda/lib/python3.10/site-packages/projects/__init__.py'
>>> 

My env is a docker image (thanosch/mmtorch:2.1.0-cuda121) with Python 3.10 and the latest version of mm:

  • mmcv 2.1.0
  • mmdet 3.2.0
  • mmengine 0.9.0
  • mmpose 1.2.0
@hhaAndroid
Copy link
Collaborator

@achariso This operation is not supported under the project. You need to prepare the configuration and weights.

@Jordan-Pierce
Copy link

@hhaAndroid can you please elaborate?

@LokeshJatangi
Copy link

LokeshJatangi commented Nov 2, 2023

@Jordan-Pierce I could solve the above error , by adding path to mmdetection to python path or through sys.path.append(path_to_mmedetection_dir)

@charisoudis
Copy link
Author

Adding to @LokeshJatangi 's solution, one has to modify the config imports as well.

@bibekyess
Copy link

#11913 provides a simple fix to this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants