Issue with relative paths in data.yaml file when trying to train yolo custom model
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- python
- Domain
- computer-vision, machine-learning
Research direction
Start with the data.yaml paths and the train_custom_dataset_yolo entry point, then reproduce training with the shown relative paths and compare the resolved path with the absolute-path case. Trace why the dataset path is repeated and verify that training can find the train and val directories using relative paths on another machine.
Written by the indexing model from the issue text.
Description
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.
- Dominant language
- Python
- Stars
- 642
- Forks
- 146
- Avg merge
- 1d 10h
- Merged PRs (30d)
- 13
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from roboflow/roboflow-python
-
`--json` output is not valid JSON for `search --export`, `image upload <dir>`, `model upload` and `version download`Possibly taken @cdeil claimed this 37 days ago. Open
Difficulty 3/5 1-2 days Newbie friendliness 20/100
roboflow/roboflow-python#546 ·
Maintainers usually reply within 1 day
-
Failed uploads are reported as success: Version.deploy() / Workspace.deploy_model() don't raise, and roboflow model upload / roboflow image upload <dir> exit 0May be free again A pull request for this issue was closed without being merged. Open
Difficulty 4/5 3-5 days Newbie friendliness 55/100
roboflow/roboflow-python#545 ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
roboflow/roboflow-python#505 · 2 comments ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 30/100
roboflow/roboflow-python#433 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
roboflow/roboflow-python#429 ·
Maintainers usually reply within 1 day
All issues in roboflow/roboflow-python
Similar issues
-
Unknown stop ID in slow zone data crashes post formatting and skips the rest of that day's postsOpenbackend bug tm-new-volunteer
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
transitmatters/mbta-slow-zone-bot#81 · 1 comment ·
-
area:schema documentation
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
risk:high type:ci
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
spacetelescope/rdmt-spire#49 ·
Maintainers usually reply within 1 day