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

How to auto create/export/produce annotation files for objects yolo detects on image? #6240

Open
easy-and-simple opened this issue Jul 14, 2020 · 11 comments
Labels
Feature-request Any feature-request

Comments

@easy-and-simple
Copy link

easy-and-simple commented Jul 14, 2020

Hello
I want to train my model to detect few classes, lets say, cats, dogs, humans but I am not happy with images in dataset I have, so I need to find images that I need and to make annotations for them in pascal voc format.
I don't want to use some tool to create annotations manually, so I need to use yolo to detect objects on images I supply and in addition of drawing object boxes to write and annotation file for every image with data for all objects.
I searched for way how to set yolo to create/export annotation files when detection objects but didn't found info if this is possible and if it is what I need to do to set yolo to do the job

So how to set yolo to create/export/produce annotation files in pascal voc and other formats for objects detected in images I have, and how to set yolo to process all images in given folder?

If there is no such option could you implement it, because it is very easy to implement and very useful and needed

@easy-and-simple easy-and-simple added the Feature-request Any feature-request label Jul 14, 2020
@biparnakroy
Copy link

biparnakroy commented Jul 15, 2020

i did a similar project on this have a look : https://github.com/biparnakroy/pseudoLabelGeneratorForYOLO
then u can convert the yolo labels to pascal VOC using this repo:
https://github.com/hai-h-nguyen/Yolo2Pascal-annotation-conversion

@AlexeyAB
Copy link
Owner

https://github.com/AlexeyAB/darknet#how-to-use-on-the-command-line

Pseudo-lableing - to process a list of images data/new_train.txt and save results of detection in Yolo training format for each image as label <image_name>.txt (in this way you can increase the amount of training data) use: ./darknet detector test cfg/coco.data cfg/yolov4.cfg yolov4.weights -thresh 0.25 -dont_show -save_labels < data/new_train.txt

@easy-and-simple
Copy link
Author

Hello guys,
Thank you for your replays!

@AlexeyAB
It is not working. I get following error:
Cannot load image "-dont_show"
STB Reason: can't fopen

@sa7ina
Copy link

sa7ina commented Jul 16, 2020

After you generate labels with yolo the classes have their numbers with the pretrained class number.
If you want to remap them to your custom class numbers i wrote a simple remapping tool for that a few days ago:
https://github.com/sa7ina/YOLOv2-5_Class_Remap

@biparnakroy
Copy link

@easy-and-simple even i faced the same issue while using -save_results and -dont_show

@easy-and-simple
Copy link
Author

easy-and-simple commented Jul 16, 2020

I make it working. Probably problem was that absolute path to files need to be supplied, but it is far away from the truth, because now I will need to covert it somehow
BTW, I would not find problem so quickly, but in Windows dir /b /s that I used to fill txt file is displaying full path to files, so it resolved issue instead me

@biparnakroy
Copy link

ok so here's the thing the model outputs the coordinates of the top left corner of the bounding box, whereas the labels need the coordinates of the center of the bounding box, that might be the problem, so u need to convert those

@AlexeyAB
Copy link
Owner

It works well:

image

image

image

@easy-and-simple
Copy link
Author

@AlexeyAB
So in order to work, path to images needs to be absolute right?
Also this functionality is not enough for my needs because I can't see how correct are bounding boxes and labels. I expect good accuracy but I must be sure that all is OK and I am not wasting time to train my model on wrong data.

@biparnakroy
I needed some very quick and easy solution, that I can use without effort, but I probably will need to find time to make some copy/paste programming and to make something that will do the job as I need it. Also values that it writes to these files are obviously not in pixels

@biparnakroy
Copy link

@easy-and-simple yolo follows this format : AlexeyAB/Yolo_mark#60 (comment)
beside u can use this https://github.com/biparnakroy/pseudoLabelGeneratorForYOLO its basically what you wanted

@AlexeyAB
Copy link
Owner

So in order to work, path to images needs to be absolute right?

I use relative paths, content of my images.txt file:

image1.jpg
image2.jpg
image3.jpg

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature-request Any feature-request
Projects
None yet
Development

No branches or pull requests

4 participants