MuhammadMoinFaisal / YOLOv8-DeepSORT-Object-Tracking

YOLOv8 Object Tracking using PyTorch, OpenCV and DeepSORT
666 stars 197 forks source link

ImportError: cannot import name 'DEFAULT_CONFIG' from 'ultralytics.yolo.utils' #5

Closed wangshuangbin closed 1 year ago

wangshuangbin commented 1 year ago

hello all do you all guys also have this issue, just like below description

    Traceback (most recent call last):

File "predict.py", line 14, in from ultralytics.yolo.utils import DEFAULT_CONFIG, ROOT, ops ImportError: cannot import name 'DEFAULT_CONFIG' from 'ultralytics.yolo.utils' (C:\Users\whs6szh.conda\envs\py38\lib\site-packages\ultralytics\yolo\utils__init__.py)

MuhammadMoinFaisal commented 1 year ago

Hi @wangshuangbin, I have checked it, it is working fine, can you please run the colab script file, and let me know if you face this issue

wangshuangbin commented 1 year ago

here is the command i use, i don't think there is any issue, do you think that maybe the ultralytic version is not correct? i use ultralytics-8.0.36

(py38) xxxx\01_DL\YOLOv8-DeepSORT\ultralytics\yolo\v8\detect>python predict.py model=yolov8l.pt source="test3.mp4" show=True Traceback (most recent call last): File "predict.py", line 14, in from ultralytics.yolo.utils import DEFAULT_CONFIG, ROOT, ops ImportError: cannot import name 'DEFAULT_CONFIG' from 'ultralytics.yolo.utils' (C:\Users\whs6szh.conda\envs\py38\lib\site-packages\ultralytics\yolo\utils__init__.py)

wangshuangbin commented 1 year ago

@MuhammadMoinFaisal hello guys, i already know the reason for this error, is the version of ultralytics-8.0.36 not match, i had tried another version 8.0.0, and already have no this issue

KongBuZhanTieRen commented 1 year ago

thanks for your sharing,I have adopted your method and successfully solve my problem

z920452974 commented 1 month ago

Hi @wangshuangbin, I have checked it, it is working fine, can you please run the colab script file, and let me know if you face this issue

Hello, when I run your code with my trained model on my test video, it shows the following error. (PS. My trained model is about damaged lane marking)

Traceback (most recent call last):
  File "E:\YOLOv8-DeepSORT-Object-Tracking-main\ultralytics\yolo\v8\detect\predict.py", line 253, in predict
    predictor()
  File "E:\anaconda3\envs\Object_counting\Lib\site-packages\torch\utils\_contextlib.py", line 115, in decorate_context
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "E:\anaconda3\envs\Object_counting\Lib\site-packages\ultralytics\yolo\engine\predictor.py", line 164, in __call__
    model = self.model if self.done_setup else self.setup(source, model)
                                               ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "E:\anaconda3\envs\Object_counting\Lib\site-packages\ultralytics\yolo\engine\predictor.py", line 121, in setup
    model = AutoBackend(model, device=device, dnn=self.args.dnn, fp16=self.args.half)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "E:\anaconda3\envs\Object_counting\Lib\site-packages\ultralytics\nn\autobackend.py", line 73, in __init__
    model = attempt_load_weights(weights if isinstance(weights, list) else w,
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "E:\anaconda3\envs\Object_counting\Lib\site-packages\ultralytics\nn\tasks.py", line 303, in attempt_load_weights
    ckpt = torch.load(attempt_download(w), map_location='cpu')  # load
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "E:\anaconda3\envs\Object_counting\Lib\site-packages\torch\serialization.py", line 1025, in load
    return _load(opened_zipfile,
           ^^^^^^^^^^^^^^^^^^^^^
  File "E:\anaconda3\envs\Object_counting\Lib\site-packages\torch\serialization.py", line 1446, in _load
    result = unpickler.load()
             ^^^^^^^^^^^^^^^^
  File "E:\anaconda3\envs\Object_counting\Lib\site-packages\torch\serialization.py", line 1439, in find_class
    return super().find_class(mod_name, name)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ModuleNotFoundError: No module named 'ultralytics.nn.modules.conv'; 'ultralytics.nn.modules' is not a package

I have tried to upgrade ultralytics with pip install ultralytics --upgrade (version 8.2.16). When I run the code again, it shows:

Traceback (most recent call last):
  File "E:\kuangbiao\object_count\YOLOv8-DeepSORT-Object-Tracking-main\ultralytics\yolo\v8\detect\predict.py", line 13, in <module>
    from ultralytics.yolo.engine.predictor import BasePredictor

Could you please help me to find problems? Thanks a lot.