open-mmlab / mmdetection

OpenMMLab Detection Toolbox and Benchmark
https://mmdetection.readthedocs.io
Apache License 2.0
29.71k stars 9.48k forks source link

Import class outside of MMDetection #11508

Open shani-sony opened 9 months ago

shani-sony commented 9 months ago

Hi! Can I import a class of a model from a directory outside of the MMDetection directory without making it a package?

PeterVennerstrom commented 8 months ago

To make a class importable and buildable by config definition MMEngine has an interface to define custom imports.

The custom code must be in path. You may find making a small package the easiest way to put the code in path, but there are work arounds.

The K-Net codebase is a nice example of using mim to train and placing the code in path by adjusting the env variable in the command.