AlexeyAB / darknet

YOLOv4 / Scaled-YOLOv4 / YOLO - Neural Networks for Object Detection (Windows and Linux version of Darknet )
http://pjreddie.com/darknet/
Other
21.65k stars 7.96k forks source link

Annotating Images that contain large number of class #1414

Open shuntos opened 6 years ago

shuntos commented 6 years ago

I am training custom model . I have four different class to detect (ie Bus, Car, Truck, bike ) video frame of cctv camera in road. I have 3000 images , in which many images have all of these objects. some of images have have two object, some of have one object.

How to annotate them?

I have tried following steps for training

1) Create four different folders and named it ,001,002,003,004 2) Put all 3000 images in all four directory (Total 12000 images) 3) Rename all images inside each directory like .( bus_1.jpg,bus_2.jpg……..,bus_3000.jpg) (car_1.jpg,car_2.jpg,……….,car_3000.jpg) for all directory.

For example , For annotation of 001, I annotate all images which contain bus only and leave images that have not bus inside it. My question is how yolo treat that unlabeled images which corresponding label.txt contain null value. How to annotate these images to detect 4 classes precisely.

AlexeyAB commented 6 years ago

You should have 1 directory with 3000 images, on each image should be labeled all objects.

https://github.com/AlexeyAB/darknet#how-to-improve-object-detection

check that each object are mandatory labeled in your dataset - no one object in your data set should not be without label. In the most training issues - there are wrong labels in your dataset (got labels by using some conversion script, marked with a third-party tool, ...). Always check your dataset by using: https://github.com/AlexeyAB/Yolo_mark

shuntos commented 6 years ago

I have no problem with training. I just want to ask how to annotate image file that contain multiple number of object class inside it . I have 3000 images and i have to detect on 4 different classes. Input image is CCTV footage of road so there is all types of object that required to be detected.

AlexeyAB commented 6 years ago

As you can see you should label all objects in one txt-file for each jpg-image in a such format even if there are several different classes (0, 1, ...):

1 0.716797 0.395833 0.216406 0.147222
0 0.687109 0.379167 0.255469 0.158333
1 0.420312 0.395833 0.140625 0.166667

To do this, you should use software: https://github.com/AlexeyAB/Yolo_mark

https://github.com/AlexeyAB/darknet#how-to-train-to-detect-your-custom-objects

  1. You should label each object on images from your dataset. Use this visual GUI-software for marking bounded boxes of objects and generating annotation files for Yolo v2 & v3: https://github.com/AlexeyAB/Yolo_mark

It will create .txt-file for each .jpg-image-file - in the same directory and with the same name, but with .txt-extension, and put to file: object number and object coordinates on this image, for each object in new line:

Where:

- integer object number from 0 to (classes-1) - float values relative to width and height of image, it can be equal from (0.0 to 1.0] for example: = / or = / atention: - are center of rectangle (are not top-left corner) For example for img1.jpg you will be created img1.txt containing: ``` 1 0.716797 0.395833 0.216406 0.147222 0 0.687109 0.379167 0.255469 0.158333 1 0.420312 0.395833 0.140625 0.166667 ```