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

AssertionError when dumping a dataset after I uploaded a MOTS annotation. #3360

Closed
2 tasks done
hbja opened this issue Jun 23, 2021 · 9 comments · Fixed by #3612
Closed
2 tasks done

AssertionError when dumping a dataset after I uploaded a MOTS annotation. #3360

hbja opened this issue Jun 23, 2021 · 9 comments · Fixed by #3612
Assignees
Labels
bug Something isn't working

Comments

@hbja
Copy link

hbja commented Jun 23, 2021

My actions before raising this issue

Expected Behaviour

Dump to COCO 1.0 JSON

Current Behaviour

image
This assertion error shows up, no matter what kind of dump I choose. The error that shows up before that is assert shape["frame"] > curr_frame.
I have 8 other datasets that have worked fine, with no errors whatsoever. Only this one has this problem for some reason.

Steps to Reproduce (for bugs)

  1. Download the images and annotations (https://drive.google.com/drive/folders/1ujcG858m4xe8COTaf1PxONyC78mV0a7N?usp=sharing)
  2. add apple to the labels
  3. Upload the images
  4. Upload the annotation zip (instances.zip) by going to upload annotations -> MOTS PNG 1.0
  5. Dump annotations -> COCO 1.0. Then failing with an assertion error.

Context

I want to get the COCO annotations from an annotated MOTS PNG dataset.

Your Environment

I tried it on two environments with the same outcome:

  1. Directly in https://cvat.org/
  2. In my Linux computer, running Ubuntu 18.04, the latest Docker (version 20).
@zhiltsov-max
Copy link
Contributor

Hi. Please describe the uploaded annotations more precise so we could reproduce the problem.

As a quick solution for the format conversion problem, you can try to use Datumaro for this:

pip install datumaro
datum convert -i mots/dir/ -if mots -o coco/dir/ -f coco -- --reindex=1

Reference: https://github.com/openvinotoolkit/datumaro/blob/develop/docs/user_manual.md#convert-datasets
Expected layout of MOTS dataset: https://github.com/openvinotoolkit/datumaro/tree/develop/tests/assets/mots_dataset
COCO format doc: https://github.com/openvinotoolkit/datumaro/blob/develop/docs/formats/coco_user_manual.md#export-to-coco

@hbja
Copy link
Author

hbja commented Jun 29, 2021

I actually managed to solve the problem. There was a faulty track on the annotations, and removing that particular faulty track solved the problem. I still don't know why that happened though.
I installed datumaro and tried to convert the format but it returned an error of
Object of type 'int64' is not JSON serializable
maybe that could be an issue by itself?

The annotations were annotated in CVAT a while ago by a colleague, and I was handed these MOTS images and instances, I'm not really sure about the details.

Unfortunately, while the problem in CVAT is solved, another problem arose. The dumped COCO annotations are reversed (eg. id: 1 is image number 70, the last image in the task, id: 2 is 69, and so on). Quite similar to this issue opened a few days ago:
#3366. Is there a fix for this? And also the datumaro issue?
Any support would be very appreciated.

EDIT: For datumaro, the Object of type 'int64' is not JSON serializable error shows up right before the "track_id" is printed. If that is any help.

@zhiltsov-max
Copy link
Contributor

Thanks for the information, it is really helpful. Regarding the int64 problem, could you provide the stack trace? It could greatly help in resolving the problem. As I understand, you are trying to export in COCO format.

@hbja
Copy link
Author

hbja commented Jun 29, 2021

Yes that's right, I'm trying to export in COCO format. Here is the stack trace of the error:

2021-06-29 11:40:52,660 INFO: Exporting the dataset
2021-06-29 11:43:00,210 ERROR: Object of type 'int64' is not JSON serializable
Traceback (most recent call last):
File "/home/hilmy/.local/bin/datum", line 8, in
sys.exit(main())
File "/home/hilmy/.local/lib/python3.6/site-packages/datumaro/cli/main.py", line 126, in main
return args.command(args)
File "/home/hilmy/.local/lib/python3.6/site-packages/datumaro/cli/commands/convert.py", line 107, in convert_command
dataset.export(format=args.output_format, save_dir=dst_dir, **extra_args)
File "/home/hilmy/.local/lib/python3.6/site-packages/datumaro/util/init.py", line 197, in wrapped_func
func(*args, **kwargs)
File "/home/hilmy/.local/lib/python3.6/site-packages/datumaro/components/dataset.py", line 599, in export
converter.convert(self, save_dir=save_dir, **kwargs)
File "/home/hilmy/.local/lib/python3.6/site-packages/datumaro/components/converter.py", line 32, in convert
return converter.apply()
File "/home/hilmy/.local/lib/python3.6/site-packages/datumaro/plugins/coco_format/converter.py", line 660, in apply
'%s_%s.json' % (task.name, subset_name)))
File "/home/hilmy/.local/lib/python3.6/site-packages/datumaro/plugins/coco_format/converter.py", line 101, in write
json.dump(self._data, outfile)
File "/usr/lib/python3.6/json/init.py", line 179, in dump
for chunk in iterable:
File "/usr/lib/python3.6/json/encoder.py", line 430, in _iterencode
yield from _iterencode_dict(o, _current_indent_level)
File "/usr/lib/python3.6/json/encoder.py", line 404, in _iterencode_dict
yield from chunks
File "/usr/lib/python3.6/json/encoder.py", line 325, in _iterencode_list
yield from chunks
File "/usr/lib/python3.6/json/encoder.py", line 404, in _iterencode_dict
yield from chunks
File "/usr/lib/python3.6/json/encoder.py", line 404, in _iterencode_dict
yield from chunks
File "/usr/lib/python3.6/json/encoder.py", line 437, in _iterencode
o = _default(o)
File "/usr/lib/python3.6/json/encoder.py", line 180, in default
o.class.name)
TypeError: Object of type 'int64' is not JSON serializable

Thanks a lot in advance!

@zhiltsov-max zhiltsov-max added the bug Something isn't working label Jun 29, 2021
@Saharkakavand
Copy link

Saharkakavand commented Sep 2, 2021

@zhiltsov-max
I annotated my dataset for instance segmentation, when I export them, wrong labels are exported. I also exported them with different formats. I attached the image of the exported mask, as you can see two different instance has the same value, but when I see the labeld image from cvat, they have different labels. Please let me know how can I solve this issue. Thanks
3534F254-FD15-4ED4-918F-68B8ADD846FB
B4943BFC-A869-43E7-9232-273281A4F071

@zhiltsov-max
Copy link
Contributor

@Saharkakavand, please explain what's on the screenshots. It looks like segmentation masks from the "Segmentation Mask" format. If it is true, you should look in the SegmentationObject directory.

@Saharkakavand
Copy link

@zhiltsov-max
It is exactly image of the SegmentationObject directory. Both of them are the same image, I want to show how two different instances got the same value of 96, which is wrong. They should be different.

@zhiltsov-max
Copy link
Contributor

This format uses 8 bits per instance code, so the maximum number of distinct instances should be 256. I assume, there could be more instances than this number. Consider using another format (COCO, Datumaro, CVAT for images, Cityscapes for example). There are also few options, but they require some changes in code.

@Saharkakavand
Copy link

@zhiltsov-max
I tried Mots and cvat, it has the same problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants