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

COCO export not working for polygons with 2 points only #955

Open
stanbiryukov opened this issue Dec 13, 2019 · 24 comments · Fixed by #975
Open

COCO export not working for polygons with 2 points only #955

stanbiryukov opened this issue Dec 13, 2019 · 24 comments · Fixed by #975
Assignees
Labels
enhancement New feature or request

Comments

@stanbiryukov
Copy link

I'm unable to export annotations to COCO format on the latest master branch. Might be a pycocotools versioning issue.

Could not dump annotations for the task 4
Error: Request failed with status code 500. "cvat.apps.engine.utils.InterpreterError: Exception at line 307: input type is not supported.\n".

And here's the relevant error in docker:

cvat          | 2019-12-13 16:00:22,023 DEBG 'rqworker_default_0' stderr output:
cvat          | 16:00:22 cvat.apps.engine.utils.InterpreterError: Exception at line 307: input type is not supported.
cvat          | Traceback (most recent call last):
cvat          |   File "/home/django/cvat/apps/engine/utils.py", line 45, in execute_python_code
cvat          |     exec(source_code, global_vars, local_vars)
cvat          |   File "<string>", line 1, in <module>
cvat          |   File "<string>", line 319, in dump
cvat          |   File "<string>", line 250, in insert_annotation_data
cvat          |   File "<string>", line 141, in polygon_area_and_bbox
cvat          |   File "pycocotools/_mask.pyx", line 307, in pycocotools._mask.frPyObjects
cvat          | Exception: input type is not supported.
@nmanovic
Copy link
Contributor

@stanbiryukov , Can you reproduce the problem on develop branch as well?

@nmanovic nmanovic added the bug Something isn't working label Dec 13, 2019
@nmanovic nmanovic added this to the 1.0.0 - Beta milestone Dec 13, 2019
@stanbiryukov
Copy link
Author

My mistake - just double checked and the above error was on the develop branch.

Master is not letting me login

Could not check authorization on the server
Error: Network Error.

@nmanovic
Copy link
Contributor

@stanbiryukov , master should work fine. But let's concentrate on the issue. Can it be reproduced on a task without annotations? Is it a task with video or images?

@stanbiryukov
Copy link
Author

Restarted docker, switched and logged in to master and getting the same error.
I'm working on an image task and confirmed that export works fine without annotations.
The issue might be a bit more complicated since I'm working with an originally uploaded COCO dataset. If I restart and create a new annotation project I'm able to export to COCO successfully.

@stanbiryukov
Copy link
Author

Note that CVAT xml exports work just fine so this might be a pycoco related issue and not cvat.

@nmanovic
Copy link
Contributor

@stanbiryukov , if you can give us some steps to reproduce the problem it will be easy for us to investigate. In any case CVAT should handle the problem gratefully.

@nmanovic
Copy link
Contributor

A possible way to export the task as datumaro project and put it here. It will not have any images. Only annotations in an internal format. Probably it will give us some ideas how to reproduce.

@stanbiryukov
Copy link
Author

Thanks - here's the datumaro export.

task_imprints-2019_12_13_16_35_05-datumaro_project.zip

@zhiltsov-max
Copy link
Contributor

As far as I understand, initially you used export annotations button? Could you try using export a dataset?

@stanbiryukov
Copy link
Author

Exporting as MS COCO dataset does not work either - same type error:

cvat          | Exception: input type is not supported.
cvat          | Traceback (most recent call last):
cvat          |   File "/usr/local/lib/python3.5/dist-packages/rq/worker.py", line 812, in perform_job
cvat          |     rv = job.perform()
cvat          |   File "/usr/local/lib/python3.5/dist-packages/rq/job.py", line 588, in perform
cvat          |     self._result = self._execute()
cvat          |   File "/usr/local/lib/python3.5/dist-packages/rq/job.py", line 594, in _execute
cvat          |     return self.func(*self.args, **self.kwargs)
cvat          |   File "/home/django/cvat/apps/dataset_manager/task.py", line 331, in export_project
cvat          |     server_url=server_url)
cvat          |   File "/home/django/cvat/apps/dataset_manager/task.py", line 221, in export
cvat          |     save_dir=save_dir, save_images=save_images)
cvat          |   File "/home/django/datumaro/datumaro/components/project.py", line 521, in export
cvat          |     converter(dataset, save_dir)
cvat          |   File "/home/django/datumaro/datumaro/components/converters/ms_coco.py", line 422, in __call__
cvat          |     converter.convert()
cvat          |   File "/home/django/datumaro/datumaro/components/converters/ms_coco.py", line 406, in convert
cvat          |     task_conv.save_annotations(item)
cvat          |   File "/home/django/datumaro/datumaro/components/converters/ms_coco.py", line 190, in save_annotations
cvat          |     rles = mask_utils.frPyObjects(segmentation, h, w)
cvat          |   File "pycocotools/_mask.pyx", line 307, in pycocotools._mask.frPyObjects
cvat          | Exception: input type is not supported.

@zhiltsov-max
Copy link
Contributor

As far as I can see, the issue is here, the code fails because of there is a polygon with only 2 points, and it comes first in the array. Interesting.

@stanbiryukov
Copy link
Author

Perhaps the best approach is to add a warning and skip those types of segments upon export or original import? I do see the 2 point polygon in the CVAT xml file now. The CVAT api correctly doesn't allow for creation of polygons with less than 3 points.

@stanbiryukov
Copy link
Author

stanbiryukov commented Dec 18, 2019

Looks like with the new commit and this use case, there is now an error Unable to import annotation #1113: a polygon has too few points (2) @zhiltsov-max @nmanovic

Is it possible to skip over the problematic polygons instead of breaking the entire import? In this case I have thousands of annotations that can no longer be imported because of a few polygon errors.

@nmanovic
Copy link
Contributor

@stanbiryukov , let us understand better the problem. How did you get annotations with only 2 points for a polygon?

@stanbiryukov
Copy link
Author

@nmanovic I originally used a different annotation tool with this project: https://github.com/jsbroks/coco-annotator

I suppose I can try and manually edit the JSON file, however, from a user perspective, it seems most intuitive that the import raises a warning and skips problematic polygons instead of breaking the import.

@nmanovic
Copy link
Contributor

@zhiltsov-max , what do you think? What is the best way to go here from your perspective?

My thoughts:
I think datumaro can have special options (e.g. --fix or --ignore-problems or --skip-issues) to import such bad annotations and export them into a valid COCO file again. I don't think that in CVAT we should ignore errors but for the case we can give a tool (datum.py) which will "filter" bad cases for the user and produces a valid COCO file which can be uploaded.

@nmanovic nmanovic reopened this Dec 19, 2019
@nmanovic nmanovic changed the title COCO export not working COCO export not working for polygons with 2 points only Dec 19, 2019
@zhiltsov-max
Copy link
Contributor

The idea to provide means in Datumaro to deal with the issue sounds well for me. What could be the good strategy of handling this, just ignoring the wrong annotations?

@nmanovic
Copy link
Contributor

@zhiltsov-max ,

What could be the good strategy of handling this, just ignoring the wrong annotations?

Let's ignore and print a warning on the console.

@stanbiryukov
Copy link
Author

Hi there - any update on the raised warning strategy for converting annotations?

@zhiltsov-max
Copy link
Contributor

It will be like stated above - in CVAT will be an error, in Datumaro will be an option to ignore corrupted annotations.

@zhiltsov-max
Copy link
Contributor

Error display during import and export operations will be tracked in #1529

@azhavoro
Copy link
Contributor

@zhiltsov-max Has this issue been resolved?

@zhiltsov-max
Copy link
Contributor

Wrong annotations are not exported or imported, but there is no option to ignore them, or to print a list of errors.

@nmanovic
Copy link
Contributor

@zhiltsov-max , it looks like it is something on what you are working now.

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

Successfully merging a pull request may close this issue.

4 participants