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

Feature/pascal voc converter #9

Merged
merged 5 commits into from
Aug 23, 2018

Conversation

syonekura
Copy link
Contributor

Fixes #2

Adds a simple script to transform CVAT XML output to PASCAL VOC format

Copy link
Contributor

@nmanovic nmanovic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍
Could you please add yourself into CONTRIBUTORS.md? If you don't want to do that it is fine.

from pascal_voc_writer import Writer


def process_cvat_xml(xml_file, img_dir, annotation_dir):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@syonekura, Thank you for the MR! I see that the script supports only "annotation" format and doesn't support "interpolation" format. What is the reason for that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I understand from XML Format, the interpolation format doesn't have a image file for each object (is a per video annotation), and it doesn't declare the path of the video file.

I'm not sure if this script should create not only the VOC XML's but also the image files from the video. If it should create them, is there an easy way to get the path of the video, or query for a specific frame of the task? If it shouldn't create the image files (for example if CVAT already let you download the interpolations as images), I still need the 'path' of those future images, is there a way to query the map between the frame number and the image filename?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@syonekura ,

Please be sure that the script will handle unsupported annotation files (like for interpolation) gracefully.

@@ -0,0 +1,42 @@
import os
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The script is very nice. Probably it will be very convenient for other users to have a short description what it does and an example how to run it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should that description go above the imports or in the description argument of argparser?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Above imports. Also what is the license for you script? MIT?


writer = Writer(filepath, width, height)

for box in img_tag.findall('box'):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Soon we are going to add polygons, polylines, points. What is your proposal? To convert them to bounding boxes or ignore?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At first I would ignore and warn, after if we find some clever ways to convert those geometries into bounding boxes we could add a parameter for the user to choose (from the top of my head I guess an application of convex hull and obtain min/max coordinates would work), but in my opinion that should be another feature proposal

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK

@@ -22,3 +22,4 @@ scipy==1.0.1
sqlparse==0.2.4
django-sendfile==0.3.11
dj-pagination==2.3.2
pascal-voc-writer==0.1.4
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think if we have separate requirements.txt file for scripts directory? Does it make sense?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it depends on the amount of scripts that CVAT will have and how does the requirements grow for each one, if there will be already two scripts (coco and pascal) and each one has their own requirements, it may be a good idea to split them from the base. Should I move the requirement to a new cvat/requirements/scripts.txt?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@syonekura ,

Current internal branch has the following structure:

cvat/utils/
    convert_to_coco.py
    convert_to_mask.py
    doc/
        convert_to_coco.md
        convert_to_mask.md
    README.md
    requirements.txt

CONTRIBUTORS.md Outdated
@@ -18,5 +18,6 @@
# Contributors

- **[Victor Salimonov](https://github.com/VikTorSalimonov)**
- **[Sebastián Yonekura](https://github.com/syonekura)**
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Victor did documentation and screen casts. I expect to see:

- **[Sebastián Yonekura](https://github.com/syonekura)**

  * [convert_to_voc.py](utils/convert_to_voc.py) - an utility for converting CVAT XML to PASCAL VOC data annotation format.

@nmanovic
Copy link
Contributor

@syonekura ,

Please rebase your changes otherwise to many commits from origin/master in the diff. I hope to merge your contributions soon. Please notify me when you are ready. Thank you!

@syonekura
Copy link
Contributor Author

@nmanovic I think we're ready, I added the warnings for the interpolation format and the unsupported geometries

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

Successfully merging this pull request may close these issues.

2 participants