You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, i'm using the 2.19.0 version of mmdet. when running python ./tools/train.py configs/det/solo/solov2_r50_fpn_coco.py, the model can not import the custommd in the dir .
Traceback (most recent call last):
File "./tools/train.py", line 190, in<module>main()
File "./tools/train.py", line 92, in main
cfg = Config.fromfile(args.config)
File "/home/ubuntu/anaconda3/envs/hyq/lib/python3.7/site-packages/mmcv/utils/config.py", line 337, in fromfile
import_modules_from_strings(**cfg_dict['custom_imports'])
File "/home/ubuntu/anaconda3/envs/hyq/lib/python3.7/site-packages/mmcv/utils/misc.py", line 75, in import_modules_from_strings
import_module(imp)
File "/home/ubuntu/anaconda3/envs/hyq/lib/python3.7/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 965, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'custommd'
But if I create a test.py
fromimportlibimportimport_moduleimportoscustom_imports=dict(
imports=[
"custommd.models.detectors.single_stage_ins",
"custommd.models.detectors.solov2",
"custommd.models.solov2.mask_feat_head",
"custommd.models.solov2.solov2_head",
],
allow_failed_imports=False)
defimport_modules_from_strings(imports, allow_failed_imports=False):
"""Import modules from the given list of strings. Args: imports (list | str | None): The given module names to be imported. allow_failed_imports (bool): If True, the failed imports will return None. Otherwise, an ImportError is raise. Default: False. Returns: list[module] | module | None: The imported modules. Examples: >>> osp, sys = import_modules_from_strings( ... ['os.path', 'sys']) >>> import os.path as osp_ >>> import sys as sys_ >>> assert osp == osp_ >>> assert sys == sys_ """ifnotimports:
returnsingle_import=Falseifisinstance(imports, str):
single_import=Trueimports= [imports]
ifnotisinstance(imports, list):
raiseTypeError(
f'custom_imports must be a list but got type {type(imports)}')
imported= []
forimpinimports:
ifnotisinstance(imp, str):
raiseTypeError(
f'{imp} is of type {type(imp)} and cannot be imported.')
try:
imported_tmp=import_module(imp)
print(os.getcwd())
print(imp)
exceptImportError:
ifallow_failed_imports:
warnings.warn(f'{imp} failed to import and is ignored.',
UserWarning)
imported_tmp=Noneelse:
raiseImportErrorimported.append(imported_tmp)
ifsingle_import:
imported=imported[0]
returnimportedimport_modules_from_strings(**custom_imports)
every thing goes well.
Wondering what cause the error?
The text was updated successfully, but these errors were encountered:
Exactly. It's necessary to import our current directory to the PYTHONPATH in any circumstance, which is mentioned in the README(Training and testing part).
Also, Any STAR will be appreciated if this repo helps you.
Hi, i'm using the 2.19.0 version of mmdet. when running
python ./tools/train.py configs/det/solo/solov2_r50_fpn_coco.py
, the model can not import the custommd in the dir .But if I create a test.py
every thing goes well.
Wondering what cause the error?
The text was updated successfully, but these errors were encountered: