HumanSignal / label-studio-sdk

Label Studio SDK
https://api.labelstud.io
Apache License 2.0
99 stars 61 forks source link

adding annotation to previously existing task #86

Closed nikitabelooussovbtis closed 1 year ago

nikitabelooussovbtis commented 1 year ago

I am trying to update annotations on tasks that I have already created. I am currently using this code: project.create_prediction(t) model_version=project.get_model_version() project.create_annotations_from_predictions(model_version=list(model_version)) where t is task information formatted as it is in the JSON file exported. I am running into an error requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: . I was wondering if this is the correct way to do it and what is causing this error? Thanks

makseq commented 1 year ago

If you are trying to update annotations, why don't you use PATCH api/annotations/<id>?

nikitabelooussovbtis commented 1 year ago

is that in the python code? I was trying to use the examples I found on the github and must have not noticed that.

nikitabelooussovbtis commented 1 year ago

Also I think I should clarify what I am trying to do. I am trying to add annotations to a task, as well as update ones that are there if they exsist. If it is better to remove the annotations and then add them that is fine.

makseq commented 1 year ago

Sorry, I was unclear and I wrote API commands instead of SDK.

In SDK you can use https://labelstud.io/sdk/project.html#label_studio_sdk.project.Project.update_annotation for annotation update.

SDK doesn't yet have an implementation for annotation creation. So, you can use this approach:

project_from_sdk.make_request('POST', f'/api/tasks/123/annotations/', json=kwargs)