Skip to content

cannot convert cvat xml to pascalvoc #236

@kervel

Description

@kervel

Hello,

i'm trying to export cvat xml to pascalvoc.
i'm letting cvat export the annotations to a gitrepo then i can do the following.

datum convert --overwrite -if cvat -i . -f voc_detection -o foo

eg with the very trivial annotations in attach.

this gives me the following error

<snip>
  File "/usr/local/lib/python3.8/dist-packages/datumaro/components/converter.py", line 32, in convert
    return converter.apply()
  File "/usr/local/lib/python3.8/dist-packages/datumaro/plugins/voc_format/converter.py", line 117, in apply
    self.save_subsets()
  File "/usr/local/lib/python3.8/dist-packages/datumaro/plugins/voc_format/converter.py", line 205, in save_subsets
    h, w = item.image.size
TypeError: cannot unpack non-iterable NoneType object

the fix is trivial: just add and item.image.has_data to the if on line 204 of converter.py

                    if item.has_image and item.image.has_data:
                        h, w = item.image.size
                        size_elem = ET.SubElement(root_elem, 'size')
                        ET.SubElement(size_elem, 'width').text = str(w)
                        ET.SubElement(size_elem, 'height').text = str(h)
                        ET.SubElement(size_elem, 'depth').text = ''

the coco format suffers from the same problem.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions