Setting up label-studio with a local directory
Refs:
- Adding a local folder as storage backend: Label Studio Documentation — Cloud and External Storage Integration
- Input .json tasks format: Label Studio Documentation — Import Data into Label Studio
The steps are:
- Create a local directory that will contain the files. Let’s assume
/home/sh/w/t/labelstudiodata - Create a subfolder there to keep your images, e.g.
pics, making the full path/home/sh/w/t/labelstudiodata/pics - Create your input data json.
[
{
"data": {
"ref_id": 1,
"image": "/data/local-files/?d=pics/cat1.png",
"image2": "/data/local-files/?d=pics/cat2.png",
"image3": "/data/local-files/?d=pics/cat3.png"
}
},
{
"data": {
"ref_id": 2,
"image": "/data/local-files/?d=pics/dhl1.png",
"image2": "/data/local-files/?d=pics/dhl2.png",
"image3": "/data/local-files/?d=pics/dhl3.png"
}
}
]
In the data, the paths are /data/local-files/?d=pics/cat1.png — start with /data/local-files/?d=, then the subdir, then the path to the file itself (here it’s flat: cat3.jpg)
- Start label-studio thus:
LABEL_STUDIO_LOCAL_FILES_SERVING_ENABLED=true LABEL_STUDIO_LOCAL_FILES_DOCUMENT_ROOT=/home/sh/w/t/labelstudiodata label-studio
LABEL_STUDIO_LOCAL_FILES_DOCUMENT_ROOT should point to your folder, WITHOUT the subfolder (no pics/) , and be absolute.
- Add your directory as storage backend.
Create your project as usual, and open its settings. The absolute local path is the SUBFOLDER of the document root:
“Treat every bucket as source” should be unchecked — in the documentation, they describe it differently from the screenshots, but it’s equivalent:
- 8. Import method - select “Tasks” (because you will specify file references inside your JSON task definitions)
“Check connection” should tell you if everything’s OK.
- DON’T sync the storage. Import the json you created from project import.
You should see your tasks.
- Bonus sample template for the above: []
<View> <View style="display: grid; grid-template-columns: 1fr 1fr 1fr; max-height: 300px; width: 900px"> <Image name="image1" value="$image"/>
<Image name="image2" value="$image2"/>
<Image name="image3" value="$image3"/> </View>
<Choices name="choice2" toName="image2">
<Choice value="Adult content"/>
<Choice value="Weapons"/>
<Choice value="Violence"/>
</Choices>
</View>
Nel mezzo del deserto posso dire tutto quello che voglio.
comments powered by Disqus