Set up Redis database project storage
You can also store your tasks and annotations in a Redis database. You must store the tasks and annotations in different databases. You might want to use a Redis database if you find that relying on a file-based cloud storage connection is slow for your datasets.
Currently, this configuration is only supported if you host the Redis database in the default mode, with the default IP address.
Label Studio does not manage the Redis database for you. See the Redis Quick Start for details about hosting and managing your own Redis database. Because Redis is an in-memory database, data saved in Redis does not persist. To make sure you don’t lose data, set up Redis persistence or use another method to persist the data, such as using Redis in the cloud with Microsoft Azure or Amazon AWS.
Task format for Source Redis Storage
Label Studio only supports string values for Redis databases, which should represent Label Studio tasks in JSON format.
For example:
'ls-task-1': '{"image": "http://example.com/1.jpg"}'
'ls-task-2': '{"image": "http://example.com/2.jpg"}'
...
> redis-cli -n 1
127.0.0.1:6379[1]> SET ls-task-1 '{"image": "http://example.com/1.jpg"}'
OK
127.0.0.1:6379[1]> GET ls-task-1
"{\"image\": \"http://example.com/1.jpg\"}"
127.0.0.1:6379[1]> TYPE ls-task-1
string
Create a source storage connection
From Label Studio, open your project and select Settings > Cloud Storage > Add Source Storage.
Select Redis Storage and click Next.
Configure Connection
Complete the following fields and then click Test connection:
| Field | Description |
|---|---|
| Storage Title | Enter a name to identify the storage connection. |
| Host |
Enter the IP address of the server hosting the database, or localhost.
|
| Port |
Enter the port that you can use to access the database. Default is 6379.
|
| Database Number (db) |
Enter the database number you want to use. Default is 1.
|
| Password | Optionally, enter the server password if your Redis instance requires authentication. |
Import Settings & Preview
Complete the following fields and then click Load preview to ensure you are syncing the correct data:
| Path to files | Optionally, specify the path to the database. Used as the keys prefix, values under this path are scanned for tasks. |
| Import Method | Select whether you want create a task for each file in your database or whether you would like to use a JSON/JSONL/Parquet file to define the data for each task. |
| File Name Filter | Specify a regular expression to filter database objects. Use .* to collect all objects. |
| Scan all sub-folders | Enable this option to perform a recursive scan across subfolders within your database. |
Review & Confirm
If everything looks correct, click Save & Sync to sync immediately, or click Save to save your settings and sync later.
Tip
You can also use the API to sync import storage.
Create a target storage connection
From Label Studio, open your project and select Settings > Cloud Storage > Add Target Storage.
Select Redis Storage and click Next.
Complete the following fields:
| Storage Title | Enter a name to identify the storage connection. |
| Path | Optionally, specify the path to the database. Used as the keys prefix for exported annotations. |
| Host |
Enter the IP address of the server hosting the database, or localhost.
|
| Port |
Enter the port that you can use to access the database. Default is 6379.
|
| Database Number (db) |
Enter the database number you want to use. Default is 2. You must use a different database number than your source storage.
|
| Password | Optionally, enter the server password if your Redis instance requires authentication. |
After adding the storage, click Sync.
Tip
You can also use the API to sync export storage.
Add storage with the Label Studio API
You can also use the API to programmatically create connections. See our API documentation.