8000 source storage images importation via api · Issue #9421 · cvat-ai/cvat · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

source storage images importation via api #9421

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

Closed
achrafs758 opened this issue May 13, 2025 · 2 comments
Closed

source storage images importation via api #9421

achrafs758 opened this issue May 13, 2025 · 2 comments
Labels
question Further information is requested

Comments

@achrafs758
Copy link

Hello guys, i'm wondering if there is a way to push images from my source storage to the created task via api, i have tested the following code but eventually it doesn't pass the images:

def create_task(storage_id, project_id):
    tasks_url = f"{API_BASE}/tasks"
    
    task_data = {
        "name": "New annotation task",
        "project_id": project_id,
        "source_storage": {
            "id": storage_id,
            "cloud_storage_id": None,
            "location": "local",  # Path within storage to your data
            "use_default_location": False,
        },
        "labels": [],  # Project labels will be used
        "subset": "train",  # Optional: assign a subset
        "image_quality": 70,  # Optional: image quality for compressed data
        "use_zip_chunks": True,  # Recommended for large tasks
        "use_cache": True
    }

my images are located in the root of the bucket, how can i set the prefix and send those images to this task?

@azhavoro azhavoro added the question Further information is requested label May 14, 2025
@zhiltsov-max
Copy link
Contributor
zhiltsov-max commented May 20, 2025

Hi, please consider using high-level SDK API for this:

from cvat_sdk import make_client, models
from cvat_sdk.core.proxies.tasks import ResourceType

with make_client("http://localhost", port=8080, credentials=("user", "pass")) as client:
    project_id = 42
    cloud_storage_id = 24
    
    task = client.tasks.create_from_data(
        spec=models.TaskWriteRequest(
            name="New annotation task",
            project_id=project_id,
        ),
        resources=["image1.png", "image2.jpg", ...],
        resource_type=ResourceType.SHARE,
        data_params=dict(
            cloud_storage_id=cloud_storage_id,
            image_quality=90,
        ),
    )

You need to replace source_storage with cloud_storage_id. source- and target_storage are supposed for annotation import and export correspondingly.

@achrafs758
Copy link
Author

Thank you @zhiltsov-max, that was helpful !!

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

No branches or pull requests

3 participants
0