Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error while training the dataset #8090

Closed
1 task done
cyndyNKCM opened this issue Jun 3, 2022 · 16 comments
Closed
1 task done

Error while training the dataset #8090

cyndyNKCM opened this issue Jun 3, 2022 · 16 comments
Labels
question Further information is requested Stale

Comments

@cyndyNKCM
Copy link

Search before asking

Question

Capture d’écran (42)

I am using google colab and i want to train the model but i have this error.
I didn't modify anything in the code.
How can i fix this issue please ?

Additional

No response

@cyndyNKCM cyndyNKCM added the question Further information is requested label Jun 3, 2022
@glenn-jocher
Copy link
Member

glenn-jocher commented Jun 3, 2022

@cyndyNKCM this is user error on your part. Your data yaml has no train: field.

@cyndyNKCM
Copy link
Author

Thank you @glenn-jocher.
It works well now.

@cyndyNKCM
Copy link
Author

cyndyNKCM commented Jun 3, 2022

The training process starts working but i have this error but i have a folder of images and a folder of labels. They are stored in a folder test. Same for the test.

AssertionError: train: No labels in /content/yolov5/Dataset_TrainTest/Train/Images.cache. Can not train without labels. See https://docs.ultralytics.com/yolov5/tutorials/train_custom_data

How can i fix this issue please?
@glenn-jocher

@glenn-jocher
Copy link
Member

glenn-jocher commented Jun 3, 2022

@cyndyNKCM 👋 Hello! Thanks for asking about YOLOv5 🚀 dataset formatting. Your error message means YOLOv5 can't find your labels correctly. To train correctly your data must be in YOLOv5 format. Please see our Train Custom Data tutorial for full documentation on dataset setup and all steps required to start training your first model. A few excerpts from the tutorial:

1.1 Create dataset.yaml

COCO128 is an example small tutorial dataset composed of the first 128 images in COCO train2017. These same 128 images are used for both training and validation to verify our training pipeline is capable of overfitting. data/coco128.yaml, shown below, is the dataset config file that defines 1) the dataset root directory path and relative paths to train / val / test image directories (or *.txt files with image paths), 2) the number of classes nc and 3) a list of class names:

# Train/val/test sets as 1) dir: path/to/imgs, 2) file: path/to/imgs.txt, or 3) list: [path/to/imgs1, path/to/imgs2, ..]
path: ../datasets/coco128  # dataset root dir
train: images/train2017  # train images (relative to 'path') 128 images
val: images/train2017  # val images (relative to 'path') 128 images
test:  # test images (optional)

# Classes
nc: 80  # number of classes
names: [ 'person', 'bicycle', 'car', 'motorcycle', 'airplane', 'bus', 'train', 'truck', 'boat', 'traffic light',
         'fire hydrant', 'stop sign', 'parking meter', 'bench', 'bird', 'cat', 'dog', 'horse', 'sheep', 'cow',
         'elephant', 'bear', 'zebra', 'giraffe', 'backpack', 'umbrella', 'handbag', 'tie', 'suitcase', 'frisbee',
         'skis', 'snowboard', 'sports ball', 'kite', 'baseball bat', 'baseball glove', 'skateboard', 'surfboard',
         'tennis racket', 'bottle', 'wine glass', 'cup', 'fork', 'knife', 'spoon', 'bowl', 'banana', 'apple',
         'sandwich', 'orange', 'broccoli', 'carrot', 'hot dog', 'pizza', 'donut', 'cake', 'chair', 'couch',
         'potted plant', 'bed', 'dining table', 'toilet', 'tv', 'laptop', 'mouse', 'remote', 'keyboard', 'cell phone',
         'microwave', 'oven', 'toaster', 'sink', 'refrigerator', 'book', 'clock', 'vase', 'scissors', 'teddy bear',
         'hair drier', 'toothbrush' ]  # class names

1.2 Create Labels

After using a tool like Roboflow Annotate to label your images, export your labels to YOLO format, with one *.txt file per image (if no objects in image, no *.txt file is required). The *.txt file specifications are:

  • One row per object
  • Each row is class x_center y_center width height format.
  • Box coordinates must be in normalized xywh format (from 0 - 1). If your boxes are in pixels, divide x_center and width by image width, and y_center and height by image height.
  • Class numbers are zero-indexed (start from 0).

Image Labels

The label file corresponding to the above image contains 2 persons (class 0) and a tie (class 27):

1.3 Organize Directories

Organize your train and val images and labels according to the example below. YOLOv5 assumes /coco128 is inside a /datasets directory next to the /yolov5 directory. YOLOv5 locates labels automatically for each image by replacing the last instance of /images/ in each image path with /labels/. For example:

../datasets/coco128/images/im0.jpg  # image
../datasets/coco128/labels/im0.txt  # label

Good luck 🍀 and let us know if you have any other questions!

glenn-jocher added a commit that referenced this issue Jun 3, 2022
glenn-jocher added a commit that referenced this issue Jun 3, 2022
* Improved dataset error introspection

Intended to help #8090

* Update general.py
@cyndyNKCM
Copy link
Author

Capture d’écran (44)

I have followed all the instructionsbut i still have the error

@glenn-jocher
Copy link
Member

@cyndyNKCM maybe try to delete your .cache file mentioned there and try again. If this doesn't work the problem is user error, you have not configured your dataset correctly.

@cyndyNKCM
Copy link
Author

i have deleted the cache file but i still have the same problem.

@cyndyNKCM
Copy link
Author

It is said in the picture 0 found 120 but the file of images isn't empty.

@glenn-jocher
Copy link
Member

@cyndyNKCM yes exactly, no labels are found, 120 are missing.

@cyndyNKCM
Copy link
Author

But the labels' folder is not empty.

@cyndyNKCM
Copy link
Author

Hello, i have created a function that can split the images and labels into train_images folder , train_labels folder, test_images folder, test_labels folder. The labels' folder aren't empty but i don't understand why after execution of the training cell, i have the error : no labels in folder.

@cyndyNKCM
Copy link
Author

Capture d’écran (47)

Here is an illustration of my problem. The partition of the dataset works well but the training doesn't despite the fact that the labels' folders are not empty.

@glenn-jocher
Copy link
Member

glenn-jocher commented Jun 7, 2022

@cyndyNKCM 👋 Hello! Thanks for asking about YOLOv5 🚀 dataset formatting. To train correctly your data must be in YOLOv5 format. Please see our Train Custom Data tutorial for full documentation on dataset setup and all steps required to start training your first model. A few excerpts from the tutorial:

1.1 Create dataset.yaml

COCO128 is an example small tutorial dataset composed of the first 128 images in COCO train2017. These same 128 images are used for both training and validation to verify our training pipeline is capable of overfitting. data/coco128.yaml, shown below, is the dataset config file that defines 1) the dataset root directory path and relative paths to train / val / test image directories (or *.txt files with image paths), 2) the number of classes nc and 3) a list of class names:

# Train/val/test sets as 1) dir: path/to/imgs, 2) file: path/to/imgs.txt, or 3) list: [path/to/imgs1, path/to/imgs2, ..]
path: ../datasets/coco128  # dataset root dir
train: images/train2017  # train images (relative to 'path') 128 images
val: images/train2017  # val images (relative to 'path') 128 images
test:  # test images (optional)

# Classes
nc: 80  # number of classes
names: [ 'person', 'bicycle', 'car', 'motorcycle', 'airplane', 'bus', 'train', 'truck', 'boat', 'traffic light',
         'fire hydrant', 'stop sign', 'parking meter', 'bench', 'bird', 'cat', 'dog', 'horse', 'sheep', 'cow',
         'elephant', 'bear', 'zebra', 'giraffe', 'backpack', 'umbrella', 'handbag', 'tie', 'suitcase', 'frisbee',
         'skis', 'snowboard', 'sports ball', 'kite', 'baseball bat', 'baseball glove', 'skateboard', 'surfboard',
         'tennis racket', 'bottle', 'wine glass', 'cup', 'fork', 'knife', 'spoon', 'bowl', 'banana', 'apple',
         'sandwich', 'orange', 'broccoli', 'carrot', 'hot dog', 'pizza', 'donut', 'cake', 'chair', 'couch',
         'potted plant', 'bed', 'dining table', 'toilet', 'tv', 'laptop', 'mouse', 'remote', 'keyboard', 'cell phone',
         'microwave', 'oven', 'toaster', 'sink', 'refrigerator', 'book', 'clock', 'vase', 'scissors', 'teddy bear',
         'hair drier', 'toothbrush' ]  # class names

1.2 Create Labels

After using a tool like Roboflow Annotate to label your images, export your labels to YOLO format, with one *.txt file per image (if no objects in image, no *.txt file is required). The *.txt file specifications are:

  • One row per object
  • Each row is class x_center y_center width height format.
  • Box coordinates must be in normalized xywh format (from 0 - 1). If your boxes are in pixels, divide x_center and width by image width, and y_center and height by image height.
  • Class numbers are zero-indexed (start from 0).

Image Labels

The label file corresponding to the above image contains 2 persons (class 0) and a tie (class 27):

1.3 Organize Directories

Organize your train and val images and labels according to the example below. YOLOv5 assumes /coco128 is inside a /datasets directory next to the /yolov5 directory. YOLOv5 locates labels automatically for each image by replacing the last instance of /images/ in each image path with /labels/. For example:

../datasets/coco128/images/im0.jpg  # image
../datasets/coco128/labels/im0.txt  # label

Good luck 🍀 and let us know if you have any other questions!

@cyndyNKCM
Copy link
Author

@glenn-jocher Thank you the training process works well now.

tdhooghe pushed a commit to tdhooghe/yolov5 that referenced this issue Jun 10, 2022
* Improved dataset error introspection

Intended to help ultralytics#8090

* Update general.py
@github-actions
Copy link
Contributor

github-actions bot commented Jul 10, 2022

👋 Hello, this issue has been automatically marked as stale because it has not had recent activity. Please note it will be closed if no further activity occurs.

Access additional YOLOv5 🚀 resources:

Access additional Ultralytics ⚡ resources:

Feel free to inform us of any other issues you discover or feature requests that come to mind in the future. Pull Requests (PRs) are also always welcomed!

Thank you for your contributions to YOLOv5 🚀 and Vision AI ⭐!

@github-actions github-actions bot added the Stale label Jul 10, 2022
ctjanuhowski pushed a commit to ctjanuhowski/yolov5 that referenced this issue Sep 8, 2022
* Improved dataset error introspection

Intended to help ultralytics#8090

* Update general.py
@glenn-jocher
Copy link
Member

You're welcome, @cyndyNKCM! I'm glad to hear that the training process is working well for you. If you have any more questions or need further assistance, feel free to ask anytime! Good luck with your training!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested Stale
Projects
None yet
Development

No branches or pull requests

2 participants