cvat: Downloaded xml's have unexpected tokens at top.

My actions before raising this issue

  • Read/searched the docs
  • Searched past issues

Annotations have unexpected tokens at top when downloaded via api in CVAT XML 1.1 for videos format. Downloading from UI has no issues.

Expected Behaviour

Downloaded annotations should not contain unexpected tokens.

Current Behaviour

Downloaded annotations have unexpected tokens at the top of the xml file.

Possible Solution

Steps to Reproduce (for bugs)

  1. Download a tasks annotations via rest api.

Context

Downloading a batch of annotations is practical via api, and useful in automating the process.

Your Environment

  • CVAT alpha build 1.1.0
  • OS : Centos 8

Next steps

You may join our Gitter channel for community support.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 19 (9 by maintainers)

Most upvoted comments

Hello Katarina, I have found out that downloaded files are zip files. You can save it then unzip the file and save again. It is not the best solution though but you can use the following code if you like to directly dump to xml. You need the zipfile package. You should change the same named function of CLI class.


    def tasks_dump(self, task_id, fileformat, filename, **kwargs):
        """ Download annotations for a task in the specified format
        (e.g. 'YOLO ZIP 1.0')."""
        url = self.api.tasks_id(task_id)
        response = self.session.get(url)
        response.raise_for_status()
        response_json = response.json()

        url = self.api.tasks_id_annotations_filename(task_id,
                                                     response_json['name'],
                                                     fileformat)
        while True:
            response = self.session.get(url)
            response.raise_for_status()
            if response.status_code == 201:
                break

        response = self.session.get(url + '&action=download')
        response.raise_for_status()
        fbytes = BytesIO(response.content)
        zipf = ZipFile(fbytes)
        with codecs.open(filename, 'wb') as fp:
            fp.write(zipf.read('annotations.xml'))

Best Barış

response header content type appears as ‘application/zip’ , shouldn’t it be something different? I cannot encode the byte array to utf-8

UPDATE: Apparently this is because response is a zip file, everything is fine when I contents as a zip file. But in CLI page the example is with an xml file which was the case in previous ones. Check, https://github.com/opencv/cvat/blob/develop/utils/cli/README.md

From CLI, I would prefer unzipped versions or an option to choose if possible.