from ultralytics import YOLO
model = YOLO('yolov8s-cls.pt')
model.train(data='C:/Users/bod9d/Desktop/ai_reloaded/sq', epochs=1, imgsz=64)
所以这是我的代码。我
m learning
YOLOv8 so epoch=1 to check everything is fine, But I got an error that I totally don
不懂。顺便说一句,数据集路径是绝对正确的。
Traceback (most recent call last):
File "C:\Users\bod9d\Desktop\ai_reloaded\main.py", line 5, in <module>
model.train(data='C:/Users/bod9d/Desktop/ai_reloaded/sq', epochs=1, imgsz=64)
File "C:\Users\bod9d\AppData\Local\Programs\Python\Python310\lib\site-packages\ultralytics\yolo\engine\model.py", line 370, in train
self.trainer.train()
File "C:\Users\bod9d\AppData\Local\Programs\Python\Python310\lib\site-packages\ultralytics\yolo\engine\trainer.py", line 191, in train
self._do_train(world_size)
File "C:\Users\bod9d\AppData\Local\Programs\Python\Python310\lib\site-packages\ultralytics\yolo\engine\trainer.py", line 268, in _do_train
self._setup_train(world_size)
File "C:\Users\bod9d\AppData\Local\Programs\Python\Python310\lib\site-packages\ultralytics\yolo\engine\trainer.py", line 252, in _setup_train
self.test_loader = self.get_dataloader(self.testset, batch_size=batch_size * 2, rank=-1, mode='val')
File "C:\Users\bod9d\AppData\Local\Programs\Python\Python310\lib\site-packages\ultralytics\yolo\v8\classify\train.py", line 76, in get_dataloader
loader = build_classification_dataloader(path=dataset_path,
File "C:\Users\bod9d\AppData\Local\Programs\Python\Python310\lib\site-packages\ultralytics\yolo\data\build.py", line 125, in build_classification_dataloader
dataset = ClassificationDataset(root=path, imgsz=imgsz, augment=augment, cache=cache)
File "C:\Users\bod9d\AppData\Local\Programs\Python\Python310\lib\site-packages\ultralytics\yolo\data\dataset.py", line 242, in __init__
super().__init__(root=root)
File "C:\Users\bod9d\AppData\Local\Programs\Python\Python310\lib\site-packages\torchvision\datasets\folder.py", line 309, in __init__
super().__init__(
File "C:\Users\bod9d\AppData\Local\Programs\Python\Python310\lib\site-packages\torchvision\datasets\folder.py", line 145, in __init__
samples = self.make_dataset(self.root, class_to_idx, extensions, is_valid_file)
File "C:\Users\bod9d\AppData\Local\Programs\Python\Python310\lib\site-packages\torchvision\datasets\folder.py", line 189, in make_dataset
return make_dataset(directory, class_to_idx, extensions=extensions, is_valid_file=is_valid_file)
File "C:\Users\bod9d\AppData\Local\Programs\Python\Python310\lib\site-packages\torchvision\datasets\folder.py", line 61, in make_dataset
directory = os.path.expanduser(directory)
File "C:\Users\bod9d\AppData\Local\Programs\Python\Python310\lib\ntpath.py", line 319, in expanduser
path = os.fspath(path)
TypeError: expected str, bytes or os.PathLike object, not NoneType
我什至不知道这意味着什么。数据集的路径存在并且完全正确,所以我不知道该怎么做。
我尝试使用其他数据集路径并重新安装
ultralytics
,但它无济于事。我的意思是代码很好,所以有什么问题?