英文:
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'],
)
可能会遗漏一些细节,但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
# Just the CVAT password and username
assert os.environ['FIFTYONE_CVAT_URL'], 'Set FIFTYONE_CVAT_URL env var'
assert os.environ['FIFTYONE_CVAT_PASSWORD'], 'Set FIFTYONE_CVAT_PASSWORD env var'
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'],
)
I may be missing some detail but the CVAT Api is a pain to use, while the voxel51 design is much simpler.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论