roboflow / roboflow/roboflow-python

Issue with relative paths in data.yaml file when trying to train yolo custom model

Offen
#333 0 Kommentare 1 Reaktion 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Vorherrschende Sprache
Python
Sterne
629
Forks
140
Ø Merge
2 T. 2 Std.
Gemergte PRs (30 T.)
5

Beschreibung

I am trying to create a training pipeline to train a custom yolov9 model with user inputted labeled images.

I am having an issue where if I make my data.yaml file use relative paths, I get the error:

RuntimeError: Dataset 'OIT_model/customOIT/customdatasetyolo/data.yaml' error
  Dataset 'OIT_model/customOIT/customdatasetyolo/data.yaml' images not found , missing path 'C:\GitHub\Anomaly_detection_combine\OIT_model\Anomaly_detection_combine\OIT_model\customOIT\customdatasetyolo\Anomaly_detection_combine\OIT_model\customOIT\customdatasetyolo\val'

What is even more odd, is that the path the error mentions,

'C:\\GitHub\\Anomaly_detection_combine\\OIT_model\\Anomaly_detection_combine\\OIT_model\\customOIT\\customdatasetyolo\\Anomaly_detection_combine\\OIT_model\\customOIT\\customdatasetyolo\\val'
is not a path that exists or is being requested anywhere. The actual path is

'C:\\GitHub\\Anomaly_detection_combine\\OIT_model\\customOIT\\customdatasetyolo\\val'
for some reason it is repeating the first part of the path 3 times.

This is the data.yaml file:

    path: OIT_model/customOIT/customdatasetyolo
    train: OIT_model/customOIT/customdatasetyolo/train
    val: OIT_model/customOIT/customdatasetyolo/val
    nc: 1
    names: ['5']

and this is the code that is starting training:

    def train_custom_dataset_yolo(data_path, epochs=100, imgsz=64, verbose=True):
        model = YOLO("OIT_model/yolov9c.pt")
        # Specify the save directory for training runs
        save_dir = 'OIT_model/customOIT/yolocustomtrainoutput'
        if os.path.exists(save_dir):
            for file in os.listdir(save_dir):
                file_path = os.path.join(save_dir, file)
                if os.path.isfile(file_path) or os.path.islink(file_path):
                    os.unlink(file_path)
                elif os.path.isdir(file_path):
                    shutil.rmtree(file_path)
        os.makedirs(save_dir, exist_ok=True)
        model.train(data=data_path, epochs=epochs, imgsz=imgsz, verbose=verbose, save_dir=save_dir)
        return
    train_custom_dataset_yolo('OIT_model/customOIT/customdatasetyolo/data.yaml', epochs=1,imgsz=64, verbose=True)

Very strangely however, when I replace the relative paths with absolute paths, like so:

    path: C:/GitHub/fix/Anomaly_detection_combine/OIT_model/customOIT/customdatasetyolo
    train: C:/GitHub/fix/Anomaly_detection_combine/OIT_model/customOIT/customdatasetyolo/train
    val: C:/GitHub/fix/Anomaly_detection_combine/OIT_model/customOIT/customdatasetyolo/val
    nc: 1
    names: ['5']

training works without issue. Using absolute pathing is not an option for me, as this application needs to be reproductible on others machines.

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne mit den data.yaml-Pfaden und dem train_custom_dataset_yolo-Einstiegspunkt, führe anschließend das Training mit den gezeigten relativen Pfaden erneut durch und vergleiche den aufgelösten Pfad mit dem Fall eines absoluten Pfads. Verfolge, warum der Dataset-Pfad wiederholt wird, und überprüfe, dass das Training die train- und val-Verzeichnisse mithilfe relativer Pfade auf einem anderen Rechner finden kann.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
python
Bereich
computer-vision, machine-learning
Issue-Typ
Bug
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.