YOLOv8_Efficient icon indicating copy to clipboard operation
YOLOv8_Efficient copied to clipboard

你好,为什么我推理时报错TypeError: expected str, bytes or os.PathLike object, not list

Open xqh5201314 opened this issue 2 years ago • 5 comments

Traceback (most recent call last): File "detect.py", line 162, in main(opt) File "detect.py", line 157, in main run(**vars(opt)) File "detect.py", line 99, in run model = YOLO(weights) File "/mnt/d/share/YOLOv8_Efficient/ultralytics/ultralytics/yolo/engine/model.py", line 56, in init {'.pt': self._load, '.yaml': self._new}Path(model).suffix File "/root/anaconda3/envs/yolov5/lib/python3.8/pathlib.py", line 1042, in new self = cls._from_parts(args, init=False) File "/root/anaconda3/envs/yolov5/lib/python3.8/pathlib.py", line 683, in _from_parts drv, root, parts = self._parse_args(args) File "/root/anaconda3/envs/yolov5/lib/python3.8/pathlib.py", line 667, in _parse_args a = os.fspath(a) TypeError: expected str, bytes or os.PathLike object, not list

xqh5201314 avatar Jan 06 '23 10:01 xqh5201314

我想可能是你的运行路径或者环境路径配置有误,建议朝这个方向去检查下。如果问题仍然存在,我也会在其他机器上做个测试和复现,看怎么去解决。

isLinXu avatar Jan 06 '23 13:01 isLinXu

I'm getting the same error.

kadirnar avatar Jan 09 '23 14:01 kadirnar

# Load or create new YOLO model
if isinstance(model, str):
    if model.endswith(".pt"):
        self._load(model)
    else:
        self._new(model)
elif isinstance(model, Path):
    self._load(str(model))

This code fixed the error.

kadirnar avatar Jan 09 '23 15:01 kadirnar

# Load or create new YOLO model
if isinstance(model, str):
    if model.endswith(".pt"):
        self._load(model)
    else:
        self._new(model)
elif isinstance(model, Path):
    self._load(str(model))

This code fixed the error.

Could you tell me where to add this code?

xqh5201314 avatar Jan 10 '23 03:01 xqh5201314

Sorry, I am fixing this type of problems and merging new features

isLinXu avatar Mar 21 '23 07:03 isLinXu