Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

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

オープン
#333 コメント 0 件 リアクション 1 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
python

調査の方向性

data.yaml のパスと train_custom_dataset_yolo エントリーポイントから始め、次に、示されている相対パスでトレーニングを再現し、解決されたパスを絶対パスの場合と比較します。データセットのパスが繰り返される理由を追跡し、別のマシンで相対パスを使ってトレーニングが train および val ディレクトリを見つけられることを確認します。

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
Python
スター
629
フォーク
140
平均マージ
2日 2時間
マージ済み PR(30日)
5

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

roboflow/roboflow-python のほかの issue

roboflow/roboflow-python の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。