SOLVED: YOLOv8 Classification Notebook Errors

EDIT - SOLVED: OK it turns out that somehow my YOLO CLI invocation was wrong, I was not specifying the *-cls.pt models.


Is it expected that this notebook should be functional? notebooks/notebooks/train-yolov8-classification-on-custom-dataset.ipynb at main · roboflow/notebooks · GitHub

I’m running through it and hitting errors as soon as I try to run the YOLO CLI pointed at a downloaded dataset directory. The YOLO CLI complains that I’m pointing it at a directory.

Directory Error
WARNING ⚠️ conflicting 'task=classify' passed with 'task=detect' model. Ignoring 'task=classify' and updating to 'task=detect' to match model.
Ultralytics YOLOv8.1.34 🚀 Python-3.10.12 torch-2.1.0+cu121 CUDA:0 (Tesla T4, 15102MiB)
engine/trainer: task=detect, mode=train, model=yolov8n.pt, data=/content/drive/MyDrive/<PATH>, epochs=50, time=None, patience=100, batch=16, imgsz=80, save=True, save_period=-1, cache=False, device=None, workers=8, project=None, name=train3, exist_ok=False, pretrained=True, optimizer=auto, verbose=True, seed=0, deterministic=True, single_cls=False, rect=False, cos_lr=False, close_mosaic=10, resume=False, amp=True, fraction=1.0, profile=False, freeze=None, multi_scale=False, overlap_mask=True, mask_ratio=4, dropout=0.0, val=True, split=val, save_json=False, save_hybrid=False, conf=None, iou=0.7, max_det=300, half=False, dnn=False, plots=True, source=None, vid_stride=1, stream_buffer=False, visualize=False, augment=False, agnostic_nms=False, classes=None, retina_masks=False, embed=None, show=False, save_frames=False, save_txt=False, save_conf=False, save_crop=False, show_labels=True, show_conf=True, show_boxes=True, line_width=None, format=torchscript, keras=False, optimize=False, int8=False, dynamic=False, simplify=False, opset=None, workspace=4, nms=False, lr0=0.01, lrf=0.01, momentum=0.937, weight_decay=0.0005, warmup_epochs=3.0, warmup_momentum=0.8, warmup_bias_lr=0.1, box=7.5, cls=0.5, dfl=1.5, pose=12.0, kobj=1.0, label_smoothing=0.0, nbs=64, hsv_h=0.015, hsv_s=0.7, hsv_v=0.4, degrees=0.0, translate=0.1, scale=0.5, shear=0.0, perspective=0.0, flipud=0.0, fliplr=0.5, bgr=0.0, mosaic=1.0, mixup=0.0, copy_paste=0.0, auto_augment=randaugment, erasing=0.4, crop_fraction=1.0, cfg=None, tracker=botsort.yaml, save_dir=runs/detect/train3
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/ultralytics/engine/trainer.py", line 138, in __init__
    self.data = check_det_dataset(self.args.data)
  File "/usr/local/lib/python3.10/dist-packages/ultralytics/data/utils.py", line 271, in check_det_dataset
    if zipfile.is_zipfile(file) or is_tarfile(file):
  File "/usr/lib/python3.10/tarfile.py", line 2780, in is_tarfile
    t = open(name)
  File "/usr/lib/python3.10/tarfile.py", line 1797, in open
    return func(name, "r", fileobj, **kwargs)
  File "/usr/lib/python3.10/tarfile.py", line 1863, in gzopen
    fileobj = GzipFile(name, mode + "b", compresslevel, fileobj)
  File "/usr/lib/python3.10/gzip.py", line 174, in __init__
    fileobj = self.myfileobj = builtins.open(filename, mode or 'rb')
IsADirectoryError: [Errno 21] Is a directory: '/content/drive/MyDrive/<PATH>'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/bin/yolo", line 8, in <module>
    sys.exit(entrypoint())
  File "/usr/local/lib/python3.10/dist-packages/ultralytics/cfg/__init__.py", line 582, in entrypoint
    getattr(model, mode)(**overrides)  # default args from model
  File "/usr/local/lib/python3.10/dist-packages/ultralytics/engine/model.py", line 638, in train
    self.trainer = (trainer or self._smart_load("trainer"))(overrides=args, _callbacks=self.callbacks)
  File "/usr/local/lib/python3.10/dist-packages/ultralytics/engine/trainer.py", line 142, in __init__
    raise RuntimeError(emojis(f"Dataset '{clean_url(self.args.data)}' error ❌ {e}")) from e
RuntimeError: Dataset '/content/drive/MyDrive/<PATH>' error ❌ [Errno 21] Is a directory: '/content/drive/MyDrive/<PATH>'

The other option seems to be to point it at a dataset.yaml file, which is not included in the folder download of a classification project. I’ve tried to construct a basic one, but then the CLI complains about not being able to find label files for the images.

Has the functionality of the YOLO CLI changed and these notebooks need to be updated to account for it?

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.