-
Notifications
You must be signed in to change notification settings - Fork 116
Open
Description
In the Label Studio UI, I can upload a single file, which, as far as I can tell, calls the task import endpoint api/projects/{project_id}/import with the file being specified in a multipart request. Currently, I don't see a way of doing this using the official SDK. I can achieve this by calling the internal client:
upload_response = ls._client_wrapper.httpx_client.request(
f'api/projects/{project_id}/import',
method='POST',
files={'file': (uploaded_file_name, file_content, 'image/jpeg')},
json=task,
params={'return_task_ids': True}
)
task_id = str(upload_response['task_ids'][0])However, this completely ignores the task dictionary, so it seems to be necessary to get the task id and then send another request to update the task with the task dictionary. However, it has some weird effects:
annotationsbecome just another generic field, so I don't see them in the UI.- Uploaded file gets renamed internally by adding a prefix, but when I get its new name by the upload id:
file_upload_id = upload_response['file_upload_ids'][0]
new_filename = ls.files.get(file_upload_id).file
task['data']['image'] = f'/data/{new_filename}'
ls.tasks.update(task_id, data=task, project=project_id)and then add it back to the task dictionary and update the task, the image file is not shown in the UI.
Is there a recommeded way to achieve the same UI functionality without having to register additional storages?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels