CVAT REST API用于上传文件。

huangapple go评论101阅读模式
英文:

CVAT REST API to upload files

问题

我能够使用下面的代码在CVAT的现有项目中创建一个任务,但无法上传文件,即使我尝试引用此链接:https://github.com/opencv/cvat/issues/4704

任何建议将不胜感激!

import requests

# 创建项目(这部分代码有效)
link = 'http://xx.x.xxx.xx:8080/api/tasks'
d = {
    "name": "ABC",
    "project_id": 3
}

Header = {
    "X-Organization": "ABC_labelling"
}

r = requests.post(link, data=d, headers=Header, auth=('username','pw'))
r.json
# 上传文件(这部分代码无效)
task_id = 8
link = 'http://xx.x.xxx.xx:8080/api/tasks/{task_id}/data/'
files = [
    '/Users/username/Documents/images/abc001.tif',
    '/Users/username/Documents/images/abc002.tif'
]

Header = {
    "X-Organization": "ABC_labelling",
    "Upload-Start": "true",
    "Upload-Finish": "true"
}

d = {
    "image-quality": 70,
    "server_files": files
}

r = requests.post(link, data=d, headers=Header, auth=('username','pw'))

英文:

I am able to create a Task in an existing project in CVAT using the below code, but I am unable to upload files, even if I try to reference this link here: https://github.com/opencv/cvat/issues/4704

Any advice would be greatly appreciated please!

import requests

# to create project (this works)
link = 'http://xx.x.xxx.xx:8080/api/tasks'
d = {
"name": "ABC",
"project_id": 3
}

Header = {
"X-Organization":"ABC_labelling"
}

r = requests.post(link, data=d, headers=Header, auth=('username','pw'))
r.json
# to upload file (doesn't work)
task_id = 8
link = 'http://xx.x.xxx.xx:8080/api/tasks/{task_id}/data/'
files = [
'/Users/username/Documents/images/abc001.tif', 
'/Users/username/Documents/images/abc002.tif'
]

Header = {
"X-Organization":"ABC_labelling",
"Upload-Start":"true",
"Upload-Finish":"true"
}

d = {
"image-quality": 70,
"server_files": files
}

r = requests.post(link, data=d, headers=Header, auth=('username','pw'))

答案1

得分: 1

虽然对我来说有时候有些小问题,但Voxel51是实现这一目标的最简单方式。

# 用于此运行的唯一标识符
import fiftyone as fo

# 仅需CVAT密码和用户名
assert os.environ['FIFTYONE_CVAT_URL'], '设置FIFTYONE_CVAT_URL环境变量'
assert os.environ['FIFTYONE_CVAT_PASSWORD'], '设置FIFTYONE_CVAT_PASSWORD环境变量'

dataset = fo.Dataset.from_dir(
    dataset_dir=<coco-dir-path>,
    dataset_type=fo.types.COCODetectionDataset,
)
dataset.name = "example_task_name"

anno_key = 'something_voxel51_uses'

dataset.annotate(
    anno_key,
    label_field="ground_truth",
    attributes=["iscrowd"],
    launch_editor=True,
    classes=['car','truck','person'],
)

https://docs.voxel51.com/api/fiftyone.core.collections.html#fiftyone.core.collections.SampleCollection.annotate

可能会遗漏一些细节,但CVAT Api 使用起来很痛苦,而Voxel51的设计要简单得多。

英文:

While it's sometimes a bit buggy for me. Voxel51 is by far the easiest way to achieve this.

# A unique identifier for this run
import fiftyone as fo 

#&#160;Just the CVAT password and username
assert os.environ[&#39;FIFTYONE_CVAT_URL&#39;], &#39;Set FIFTYONE_CVAT_URL env var&#39;
assert os.environ[&#39;FIFTYONE_CVAT_PASSWORD&#39;], &#39;Set FIFTYONE_CVAT_PASSWORD env var&#39;

dataset = fo.Dataset.from_dir(
    dataset_dir=&lt;coco-dir-path&gt;,
    dataset_type=fo.types.COCODetectionDataset,
)
dataset.name = &quot;example_task_name&quot;

anno_key = &#39;something_voxel51_uses&#39;

dataset.annotate(
    anno_key,
    label_field=&quot;ground_truth&quot;,
    attributes=[&quot;iscrowd&quot;],
    launch_editor=True,
    classes=[&#39;car&#39;,&#39;truck&#39;,&#39;person&#39;],
)

https://docs.voxel51.com/api/fiftyone.core.collections.html#fiftyone.core.collections.SampleCollection.annotate

I may be missing some detail but the CVAT Api is a pain to use, while the voxel51 design is much simpler.

huangapple
  • 本文由 发表于 2023年3月7日 23:07:22
  • 转载请务必保留本文链接:https://go.coder-hub.com/75663717.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定