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

I don't know how to read the documentation, please help. #7526

Closed
2 tasks done
vdanyliu opened this issue Feb 27, 2024 · 7 comments
Closed
2 tasks done

I don't know how to read the documentation, please help. #7526

vdanyliu opened this issue Feb 27, 2024 · 7 comments
Labels
documentation Documentation should be updated good first issue Good for newcomers sdk/cli

Comments

@vdanyliu
Copy link

vdanyliu commented Feb 27, 2024

Actions before raising this issue

  • I searched the existing issues and did not find anything similar.
  • I read/searched the docs

Is your feature request related to a problem? Please describe.

I don't understand how to use the cvat_sdk for python to create a job or a task... with a hundred images, each of which should have a preliminary annotation (for example, a rectangle with relative coordinates 0.0 0.0 0.5 0.5)

Describe the solution you'd like

Add more example to doc pls...

Describe alternatives you've considered

No response

Additional context

image

@vdanyliu vdanyliu added the enhancement New feature or request label Feb 27, 2024
@bsekachev bsekachev added documentation Documentation should be updated and removed enhancement New feature or request labels Feb 28, 2024
@nmanovic nmanovic added sdk/cli good first issue Good for newcomers labels Mar 1, 2024
@Oshangsurtani
Copy link

use intellij idea for using cvat_sdk with python

@vdanyliu
Copy link
Author

vdanyliu commented Mar 1, 2024

use intellij idea for using cvat_sdk with python

Thank you for the advice, but I'm already doing that and it's not helping much. I've been digging into the low-level API code for 2 days and haven't found anything that could help me with this issue.

To be honest, an example with code or a link to a similar issue would be very helpful for me.

@OmarHassan2334
Copy link

I think this code example should be able to help you, from cvat import Dataset, Task

Assuming you have a list of image paths

image_paths = ['image1.jpg', 'image2.jpg', 'image3.jpg', ...]

Initialize a dataset

dataset = Dataset()

Add images to the dataset

for path in image_paths:
dataset.add_data_entry(path)

Create a task with the dataset

task = Task(name='My Task', data=dataset)

Add annotations to each image (e.g., rectangles with relative coordinates)

for data_entry in task.data:
data_entry.add_annotation("rectangle", points=[0.0, 0.0, 0.5, 0.5])

Save the task

task.save('my_task.json')

Let me if this works for you and tell me if you need anything else. (I'm commenting this here for easier refence on your behalf I could upload to docs but i need your feedback first.)

@vdanyliu
Copy link
Author

vdanyliu commented Mar 4, 2024

Alright, thank you.
And what if each image has unique rectangle coordinates?

@Viditagarwal7479
Copy link
Contributor

for data_entry in task.data:
    data_entry.add_annotation("rectangle", points=[0.0, 0.0, 0.5, 0.5])

Change the coordinates of points in the order of followed in image_paths list.

@vdanyliu
Copy link
Author

vdanyliu commented Mar 4, 2024

Well... from which library specifically is import Dataset, Task, etc. made? And if it's not cvat_sdk, could you provide a link to the library?

@zhiltsov-max
Copy link
Contributor

Hi,

Please start from the high-level SDK documentation - it begins with a relevant example and provides information on how to perform specific actions. If you want to use lower-level APIs, you should start with this documentation page, which contains an equivalent relevant example. For annotation uploading, please check this structure (for the data structure required) - it's used both in high- and low-level APIs.

Please also check SDK tests - there you can find examples for (almost) all high-level APIs provided. Specifically, for the problem you are asking about, these tests should be helpful: task creation, custom annotation uploading and annotation patching.

Basically, you're looking for a code like this:

from cvat_sdk import make_client

with make_client(...) as client:
    task = client.tasks.create_from_data(...)
    task.update_annotations({"shapes": [{"type": "rectangle", ...}]})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Documentation should be updated good first issue Good for newcomers sdk/cli
Projects
None yet
Development

No branches or pull requests

7 participants