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

Add task_size parameter to CVAT backend #1457

Merged
merged 4 commits into from
Dec 29, 2021
Merged

Add task_size parameter to CVAT backend #1457

merged 4 commits into from
Dec 29, 2021

Conversation

ehofesmann
Copy link
Member

@ehofesmann ehofesmann commented Dec 1, 2021

Resolves #1448

The CVAT REST API imposes a limit on the size of requests. This can cause errors when uploading annotation runs for sample collections with many images or labels to CVAT.

In order to break an annotation run into smaller segments, this PR adds a task_size parameter that limits the number of samples that can be uploaded to a single task in CVAT. Due to the creation of multiple tasks when task_size is provided, we recommend providing a project_name to group the created tasks together.

The task_size parameter can be used in conjunction with segment_size to both define the number of images per task and the number of images per job within the task.

Example

import fiftyone.zoo as foz
import fiftyone as fo

dataset = foz.load_zoo_dataset("quickstart", max_samples=20).clone()

anno_key = "batch_upload"
project_name = "batch_example"

task_size = 6  # 6 images per task
segment_size = 2 # 2 images per job

results = dataset.annotate(
    anno_key,
    label_field="ground_truth",
    task_size=task_size,
    segment_size=segment_size,
    project_name=project_name,
    launch_editor=True,
)

# Annotate in CVAT

dataset.load_annotations(anno_key, cleanup=True)

Note: The CVAT maintainers are working on an update to resolve this issue natively.

@ehofesmann ehofesmann added bug Bug fixes feature Work on a feature request annotation Issues related to FiftyOne's annotation API labels Dec 1, 2021
@ehofesmann ehofesmann requested review from brimoor and a team December 1, 2021 20:15
@ehofesmann ehofesmann self-assigned this Dec 1, 2021
Copy link
Contributor

@brimoor brimoor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -2498,6 +2498,8 @@ class CVATBackendConfig(foua.AnnotationBackendConfig):
password (None): the CVAT password
headers (None): an optional dict of headers to add to all CVAT API
requests
task_size (None): an optional maximum number of images to upload per
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI- I moved task_size up here so that it appears near other relevant parameters.

I think this is more user-friendly than strictly adding new kwargs to the end, which makes it harder to grok the available options. This is also why I always recommend using key=value syntax when calling any function with kwargs, so that order can be changed later in cases like this.

@brimoor brimoor merged commit abe0725 into develop Dec 29, 2021
@brimoor brimoor deleted the cvat-batch branch December 29, 2021 17:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
annotation Issues related to FiftyOne's annotation API bug Bug fixes feature Work on a feature request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Cannot upload large CVAT annotation tasks: Request Entity Too Large
2 participants