AlexeyAB / Yolo_mark

GUI for marking bounded boxes of objects in images for training neural network Yolo v3 and v2
https://github.com/AlexeyAB/darknet
The Unlicense
1.81k stars 682 forks source link

annotatiom file conversion. #94

Open BlcaKHat opened 6 years ago

BlcaKHat commented 6 years ago

@AlexeyAB I have openImage annotation for images.

The for mat of annotation file is : (class_name X_end Y_end X_start Y_start).

where is X_start & Y_start is starting of rectangle box and X_end, Y_end is end co-ordinate of rectangle.

can you explain your logic so I can conver them to yolo format

AlexeyAB commented 6 years ago

Yolo format is: <object-class> <x> <y> <width> <height> So:

<x_center> = ((X_end + X_start) / 2) / image_width

<y_center> = ((Y_end + Y_start) / 2) / image_height

<width> = (X_end - X_start) / image_width

<height> = (Y_end - Y_start) / image_height

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

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 ```
kenrubiooo commented 5 years ago

Hi @AlexeyAB I was just wondering how can I convert the

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 a format like

0 240 240 100 150

where the image is 480x480, the box from the yolo mark has center at (240, 240) and has width of 100 and height of 150?

Thank you!