-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
Description
Iβm encountering an import error when trying to run NanoDet on the latest Python (3.12) and PyTorch versions.
It seems some internal modules are still referencing the deprecated cfg variable, which was removed in recent NanoDet versions.
Error Trace
Traceback (most recent call last):
File "test_nanodet.py", line 4, in
from nanodet.model.arch import build_model
File "nanodet/model/arch/nanodet_plus.py", line 19, in
from ..head import build_head
File "nanodet/model/head/init.py", line 3, in
from .gfl_head import GFLHead
File "nanodet/model/head/gfl_head.py", line 10, in
from nanodet.util import (
File "nanodet/util/init.py", line 8, in
from .config import cfg, load_config
ImportError: cannot import name 'cfg' from 'nanodet.util.config'
Environment
OS: Ubuntu 22.04
Python: 3.12.3
PyTorch: 2.4.0
NanoDet commit: latest (as of October 2025)
Steps to Reproduce
Clone the repo:
git clone https://github.com/RangiLyu/nanodet.git
cd nanodet
pip install -r requirements.txt
Try running:
python demo/demo.py image --config config/nanodet-plus-m_416.yml --model nanodet_m_416.ckpt --path test.jpg
Observe the ImportError.
Expected Behavior
NanoDet should load configuration correctly using the updated load_config() API and not reference deprecated globals.
Suggested Fix
Remove deprecated import:
from .config import cfg, load_config
and replace with:
from .config import load_config
in nanodet/util/init.py.