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

Not able to upload annotation file against a task #5781

Closed
2 tasks done
Idnan opened this issue Feb 27, 2023 · 3 comments
Closed
2 tasks done

Not able to upload annotation file against a task #5781

Idnan opened this issue Feb 27, 2023 · 3 comments
Labels
question Further information is requested sdk/cli

Comments

@Idnan
Copy link

Idnan commented Feb 27, 2023

My actions before raising this issue

Hi, I am trying to upload annotation file through an API against a task. But while uploading I am getting following error.

No such file were uploaded

I have also checked the logs. But don't see any errors there.

Here's my code:

const annotationData = new FormData();
annotationData.append('annotation_file', fs.createReadStream(annotationPath));

const { data: annotation } = await axiosClient
.post(
  `${host}/api/tasks/${task.id}/annotations?format=CVAT+1.1&location=local&filename=annotations.xml&conv_mask_to_poly=false`, //
  annotationData,
  {
    headers: {
      Authorization: `Token ${authToken}`,
      sessionid: sessionToken,
      csrfAuth: csrfToken,
      ...annotationData.getHeaders(),
    },
  },
);

And here's the content of the XML file that I am trying to upload.

<?xml version="1.0" encoding="utf-8"?>
<annotations>
  <version>1.1</version>
  <image id="0" name="ml-task-computer-vision-dvc-cache/session-media/366dbbe4-d216-11e9-bb34-e82a44f120e4.jpg" width="2880" height="2160">
    <points label="shrimp" source="manual" occluded="0" points="787.04,946.34" z_order="0">
    </points>
    <points label="shrimp" source="manual" occluded="0" points="844.39,1057.84" z_order="0">
    </points>
    <points label="shrimp" source="manual" occluded="0" points="1038.73,1022.80" z_order="0">
    </points>
    <points label="shrimp" source="manual" occluded="0" points="1083.33,863.50" z_order="0">
    </points>
    <points label="shrimp" source="manual" occluded="0" points="1443.33,1073.77" z_order="0">
    </points>
    <points label="shrimp" source="manual" occluded="0" points="1322.27,1242.62" z_order="0">
    </points>
    <points label="shrimp" source="manual" occluded="0" points="1398.73,1315.89" z_order="0">
    </points>
    <points label="shrimp" source="manual" occluded="0" points="1395.54,1398.73" z_order="0">
    </points>
    <points label="shrimp" source="manual" occluded="0" points="1580.32,1443.33" z_order="0">
    </points>
    <points label="shrimp" source="manual" occluded="0" points="1761.91,1299.96" z_order="0">
    </points>
    <points label="shrimp" source="manual" occluded="0" points="1755.54,1204.39" z_order="0">
    </points>
    <points label="shrimp" source="manual" occluded="0" points="1755.54,1366.87" z_order="0">
    </points>
    <points label="shrimp" source="manual" occluded="0" points="1790.58,1424.21" z_order="0">
    </points>
    <points label="shrimp" source="manual" occluded="0" points="1647.22,1051.47" z_order="0">
    </points>
  </image>
</annotations>

But when I am uploading the same annotations.xml file through CVAT UI it works.

Your Environment

  • Git hash commit (git log -1): 86a0d51
  • Docker version docker version (e.g. Docker 17.0.05): 20.10.22
  • Are you using Docker Swarm or Kubernetes? Docker Swarm
  • Operating System and version (e.g. Linux, Windows, MacOS): MacOS
@Idnan
Copy link
Author

Idnan commented Mar 6, 2023

Sorry for tagging you directly @zhiltsov-max. But will you be able to please help here?

@zhiltsov-max
Copy link
Contributor

Hi. This endpoint requires the data to be uploaded via the TUS protocol. Please use a specialized library for this, as the official CVAT UI and SDK do this. For javascript, it can be this library. If you can use python, consider using cvat-sdk. You can also use cvat-cli to upload annotations without coding.

@zhiltsov-max zhiltsov-max added question Further information is requested sdk/cli labels Mar 13, 2023
@thaikoh
Copy link

thaikoh commented Jun 9, 2023

Similar issue here with Python SDK here.

I have two CVAT instances, one on local machine, another on remote. Task creation on local machine works fine, but on remote I getting exception when I try to create task with annotations.

cvat_sdk.api_client.exceptions.ApiException: Status Code: 400
Reason: Bad Request
HTTP response headers: HTTPHeaderDict({'Allow': 'GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS', 'Content-Length': '28', 'Content-Type': 'application/vnd.cvat+json', 'Cross-Origin-Opener-Policy': 'same-origin', 'Date': 'Fri, 09 Jun 2023 09:38:52 GMT', 'Referrer-Policy': 'same-origin', 'Server': 'nginx/1.18.0 (Ubuntu)', 'Vary': 'Accept, Origin', 'X-Content-Type-Options': 'nosniff', 'X-Frame-Options': 'DENY', 'X-Request-Id': 'bf291e39-535a-48b8-bad8-20353761fa12'})
HTTP response body: b'"No such file were uploaded"'

My code:

    def create_task_(self,
                     name: str,
                     resources: List[str],
                     labels: Optional[list] = None,
                     an_file: Optional[str] = None,
                     an_format: Optional[str] = None,
                     project_id: Optional[int] = None):
        task_spec = {
            "name": name,
            "labels": labels,
            "project_id": project_id,
        }
        self._client.tasks.create_from_data(
            spec=task_spec,
            resource_type=ResourceType.LOCAL,
            resources=resources,
            annotation_format=an_format,
            annotation_path=an_file,
        )

What I'm doing wrong? Why on local it works but not on remote?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested sdk/cli
Projects
None yet
Development

No branches or pull requests

4 participants