Sardar Raheem
Sardar Raheem

Reputation: 23

yolov5 not training on custom dataset

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

Upvotes: 0

Views: 1119

Answers (2)

sk sanny
sk sanny

Reputation: 11

train: /content/drive/MyDrive/Classes/YOLOv8/data/train/images
val: /content/drive/MyDrive/Classes/YOLOv8/data/valid/images

# Classes
names:
  0: drug
  

In coco128.yml to change the datasets path only pass the path of images cannot pass the image file pass the image folder path

Upvotes: 0

smith John
smith John

Reputation: 1

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.

Upvotes: 0

Related Questions