0

I am using yolov5 to train on custom dataset my dataset.yaml file contains

path: ../testing
train: images
val: images
nc: 10
names:
  ["door", "cabinetDoor", "refrigeratorDoor", "window", "chair",
  "table", "cabinet", "couch", "openedDoor", "pole"]

The directory of dataset is as follows

CustomTraining
├── yolov5
├── testing
    ├── images
    │   ├── train  (1024 images)
    │   └── val    (230 images )
    └── labels
        ├── train
        └── val

command I run is

!cd yolov5 && python train.py --img 512 --batch 10 --epoch 100 --data dataset.yml --weights yolov5s.pt 

but when I see my runs/train directory in yolov5 folder the exp folders does not have any jpeg files and weights folders are also empty

  • As provided output . You have set the current directory to Yolov5 and run the training script . Now the script is looking for the testing directory in yolv5 folder. Provide the absolute path in data.yaml file or move the directory in yolov5 folder. – Satish Saini Apr 12 '23 at 04:44

1 Answers1

0

It been a long time,dont know whether u have solved the problem. sry that Im not capabale to embed pictures here

1:First, try to change the relative path in the yaml file into absolute path.

2:Second,In fact,here is my doc,you can have try at this.

yaml file:

train: D:\yolov5\datasets\mydata\ImageSets\Main\train.txt
 
 
val: D:\yolov5\datasets\mydata\ImageSets\Main\train.txt
 
test:  # test images (optional)

directory:

 - **D:\yolov5**    
    - yolov5-7.0(main project)
       - train.py
       - detect.py
       - .......
    - **datasets**(place I store my datas)
       - coco128
         - iamges 
         - labels
         - readme
       - **mydata**
         - images(my pictures to train)
            - IMG_000001.jpg
            - IMG_000002.jpg
            - IMG_000003.jpg
            ......
         - labels(labels for my pictures)
            - IMG_000001.txt
            - IMG_000002.txt
            - IMG_000003.txt
            ......
         - **ImageSets**
           - **Main**
             - **train.txt**

train.txt:

You need to put the path of this folder in the yaml file,yolov5 will scan this file to find your images and labels,!!!!!!!!!!!! You might doubt that this txt file is neither "images.txt" nor "labels.txt", then how does the model find the datasets they need.

So here is the content of the train.txt

 D:\yolov5\datasets\mydata\**images**\IMG_000001.jpg 
 D:\yolov5\datasets\mydata\**images**\IMG_000002.jpg 
 ......

Yes , you can see that the content of of this "train.txt" is exactly just the absolute path of the pictures that you want to train!!!

Now , you might want to ask again, "what about my labels?" The code in yolov5 will turn the word "images" in the absolute path mentioned above "D:\yolov5\datasets\mydata\images\IMG_000001.jpg" into "labels" automatically to find your labels file. So you dont need to mention your labelfile's path in this file. And that is exactly why you need to organize your directory like that. And remeber to change the name of your "labels.txt" into "IMG_000001"(just be the same as your images name is OK,"IMG_00000n" is my project name, you dont have to be like that) ,so it can find your labels with the path after changing "images" into "labels" , like"D:\yolov5\datasets\mydata\ labels \IMG_000001.jpg"

Hope I can make it clear to you guys . Thanks 4 wathcing.

M Z
  • 4,571
  • 2
  • 13
  • 27
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Apr 26 '23 at 14:10