Skip to content

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

@charisoudis

Description

@charisoudis

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions