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

Utils coco converty.py line 382 throws error with key 'z_order' #238

Closed
Paperone80 opened this issue Dec 14, 2018 · 5 comments
Closed

Utils coco converty.py line 382 throws error with key 'z_order' #238

Paperone80 opened this issue Dec 14, 2018 · 5 comments
Labels
bug Something isn't working
Milestone

Comments

@Paperone80
Copy link

Hi,

I am using cvat version from 2018-11-19. I created some images solely with polygon annotations. The converter.py under utils.coco throws the following error:

Processing images from cvat.xml: 0it [00:00, ?it/s]
Traceback (most recent call last):
File "/projects/cvat/cvat_2018-11-19/utils/coco/converter.py", line 420, in
main()
File "/projects/cvat/cvat_2018-11-19/utils/coco/converter.py", line 382, in main
image['polygon'].sort(key=lambda x: int(x['z_order']))
File "/projects/cvat/cvat_2018-11-19/utils/coco/converter.py", line 382, in
image['polygon'].sort(key=lambda x: int(x['z_order']))
KeyError: 'z_order'

This line is the culprit:
image['polygon'].sort(key=lambda x: int(x['z_order']))

I checked the output of an image['polygon'] example and it looks like the following:
print(image['polygon'])

[{'id': '8',
'label': 'label_1',
'occluded': '0',
'points': '1862.39,991.17;1815.86,956.70;983.42,1675.39;1010.99,1711.59'},
{'id': '9',
'label': 'label_1',
'occluded': '0',
'points': '1031.67,1959.77;1004.10,1930.47;1007.54,1909.79;1879.62,1275.55;1908.92,1306.57;1912.37,1325.53;1035.12,1951.15'},
{'id': '10',
'label': 'label_2',
'occluded': '0',
'points': '1509.34,3049.35;1512.31,3156.56;1491.47,3195.28;1446.79,3213.15;1399.14,3213.15;1360.43,3183.36;1378.30,2742.60;1375.32,2173.77;1375.32,2132.07;1372.34,2060.60;1372.34,2001.03;1372.34,1938.49;1372.34,1878.93;1372.34,1822.34;1372.34,1738.95;1375.32,1667.48;1369.36,1613.87;1360.43,1619.83;1342.56,1459.01;1342.56,1414.33;1336.60,1369.66;1336.60,1351.79;1339.58,1271.38;1327.67,1226.71;1357.45,1190.97;1402.12,1185.01;1440.84,1211.82;1446.79,1357.75;1464.66,1515.59;1464.66,1724.06;1503.38,2278.00;1506.36,2671.12'}]

No key 'z_order' to sort by. Uncommenting the line solved the issue for me.

@nmanovic
Copy link
Contributor

Hi @Paperone80 ,

Z-order is important to correctly overlap annotations for different objects. For example, sky can be annotated as "big bounding boxes" and other elements which are overlapped with sky can have precise boundaries. Thus it isn't necessary to draw boundaries twice.

But in any case the script should work in this case without exceptions.

@nmanovic nmanovic added the bug Something isn't working label Dec 17, 2018
@nmanovic nmanovic added this to the 0.4.0 - Alpha milestone Dec 17, 2018
@DmitriySidnev
Copy link
Contributor

Hi!
The script works with annotations with obligatory field z_order for correct processing overlapped polygons. So, to avoid this error here must be a simple fix:

if 'z_order' in polygon:
    image['polygon'].sort(key=lambda x: int(x['z_order']))

But in this case - without z_order, overlapped polygons will be cropped incorrect.
@nmanovic should it be a PR?

@nmanovic
Copy link
Contributor

Hi @DmitriySidnev ,

Yes. Let's add the "if" and also a warning about possible problems.

@Paperone80
Copy link
Author

Thanks @nmanovic, @DmitriySidnev.

Quick question, where/how is the 'z_order' information usually created?

@nmanovic
Copy link
Contributor

@Paperone80 ,

When you create an annotation task you can "check" z_order checkbox: https://github.com/opencv/cvat/blob/develop/cvat/apps/documentation/user_guide.md#creating-an-annotation-task

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

No branches or pull requests

3 participants