Retrieving Project ID and Filename Random Strings in Label Studio

,

Question:

How can I retrieve the project ID and the 8-character random string prepended to image names after uploading images to Label Studio via a GET request to the Label Studio API? Moreover, what exactly is this 8-character random string, and is it a hash intended for ensuring uniqueness for each uploaded image?

Answer:

The Label Studio API enables you to retrieve information about tasks and their associated data after you’ve imported files. Although the API documentation might not explicitly detail obtaining the project ID and filename random string, you can generally retrieve such information by accessing the task details endpoint.

To obtain the project ID and the 8-character random string for the images (which are indeed random hash symbols generated to avoid file name conflicts on the server), you can use the api/tasks endpoint. The process would involve parsing the task data to extract the file path containing both the project ID and the unique string.

Here is a general example of how you might use the API to retrieve a task and its associated data:

curl -X GET 'http://<label-studio-url>/api/tasks/' \
-H 'Authorization: Token <your_api_token>' \
-H 'Content-Type: application/json'

In the response, you’ll find details about your tasks, including information about the data URLs for any images or data points you’ve uploaded.

Keep in mind that this random string is generated by Label Studio’s underlying framework (Django) and is not a hash of the content but simply a mechanism to prevent filename collisions.

For managing uploads for larger projects, we recommend using Cloud Storages integrated into Label Studio, rather than direct file uploads via the UI, as it is more scalable and efficient for handling large datasets.