EscVM / OIDv4_ToolKit

Download and visualize single or multiple classes from the huge Open Images v4 dataset
GNU General Public License v3.0
809 stars 635 forks source link

Support for different annotation file format, such as Pascal VOC #16

Closed Sonyoyo closed 5 years ago

Sonyoyo commented 5 years ago

Hello, you tool is great and very useful. I would like to use the downloaded dataset with tensorflow so I have to build a TFRecord file from it. However, before start training, I think I am going to modify/add some labels via the labelImg tool so I firstly need to build xml files in Pascal VOC format. It looks like it is not that hard to obtain them from your txt files but I am wondering whether you consider including this file format as output of you toolkit (I am a ML newbie so I hope I am not asking something obvious...).

nilsfed commented 5 years ago

Hey @Sonyoyo,

I would like to use Tensorflow Object Detection aswell with an OIDv4 Subset. It would be great if there was support for Pascal VOC and especially TFRecord. So far I have been looking for a solution and experienced:

The .txt files generated by this ToolKit are already very similar to the YOLO format

One could use a Python Script to generate YOLO format, which labelImg also supports, so you can modify and add your labels. I also came across a Repository where you can generate TFRecords from YOLO: https://github.com/AlessioTonioni/tf-objdetector, but I did not test it personally yet.

I hope that this can help you with your problem.

@EscVM You created a great ToolKit, thank you! Do you intend to support other bounding box annotation formats besides the current one? Pascal VOC and maybe a function to generate TFRecords would be great. I am going to research this topic more and would be willing to help and contribute.

EscVM commented 5 years ago

Hi @Sonyoyo 'n' @nilsfed!

Thank you! I really appreciate it.

I totally agree, it'd be a great idea to support also different types/formats of bounding boxes and directly download all the classes in a ready to use package! However, when I've started to realize how many different types of bb there could have been I thought that the best way was to download everything with an easy format to parse. So, simply if you want to have a specific format just write it down a program that transforms all the txt files in your desired one.

Here you can find a simple example I wrote to get yolo labels from oid ones ----> https://gist.github.com/EscVM/b6e5d60343c88f358742aa9e0de2cc3f

If you write other file like my one of other common format (Pascal, COCO...) I could merge everything in the ToolKit;)

Sonyoyo commented 5 years ago

Hello,

thanks for your answers. I finally ended up creating a script to convert annotation files to PASCAL VOC format: the first test I did seems to work and I can see boxes and navigate through images in labelImg (which was my goal). There I should be able to convert to TFRecord via the scripts provided by tensorflow itself.

@EscVM : if you think that my script could be useful for other and can be integrated to your toolkit, I can provide it. You could potentially add a kind of "--Format" key in your function call to choose among available output formats.

For your information, I was forced (by labelImg) to round the coordinate of boundaries to integer since they correspond to pixels (so float were not accepted).

nilsfed commented 5 years ago

Hey,

Today I did more or less the same as @Sonyoyo already did :) I wrote a Script to reach PASCAL VOC XML format, which also works with labelImg. [For usage in labelImg both the xml files and the images should be located in the same directory, so you would need to copy the images or xml files] It checks all directories in the OID/Dataset folder and creates directories called To_PASCAL_XML right next to the original Label directories.

@EscVM : I hope you can use this script or some parts of it! --> gist link to my script If you have any questions, suggestions or need help, feel free to PM me or ask here, I think this is a great project and those annotation formats could help some people to modify/add labels and start training a model ;)

martinbel commented 5 years ago

It seems the conversion to VOC format is already available here. Otherwise the process seems to be to get all bounding boxes for each image and the classes you care and save an xml file for each image.

MitraTj commented 5 years ago

Hi. The tool created by you is great. Actually, I need to use pytorch visual relation detection with this dataset. And I want to know which strategy I need to follow? (download multiple classes at the same time creating separated folder and bounding boxes for each of them or download multiple classes and creating a common folder for all of them with a unique annotation file of each image). thanks!

keldrom commented 5 years ago

@MitraTj is up to you this decision. It depends on how you want to train your network.

keldrom commented 5 years ago

Guys it seems that this issue is solved and so I'm going to close it. If you needs some other helps don't hesitate and contact us. Thank you for the feedback and supports :D