Label-studio: How could I load image from local Source Storage?

Created on 8 Apr 2021  路  8Comments  路  Source: heartexlabs/label-studio

Hi, I have followed the doc here to create a local storage.
a

And then I start to use the local storage by two steps.

  1. Put .*png file into the local path that I select above.
  2. Import my tasks through the json file below with the image value("original_image") inside the red box.
    b

However, I failed to load the image through this way as below.
c

Could you help me with the bug? Looking forward to your reply.

documentation

Most helpful comment

@smoreface Please, could you add to this doc section
https://labelstud.io/guide/tasks.html#Import-data-from-a-local-directory
a task example with the correct path to file (and maybe some note about /data/local-files/ path), like:

```
{
"data": {
"image": "/data/local-files/1.jpg"
}
}

All 8 comments

Hi!
For Local files storage you have to use /data/local-files/1.png.

@smoreface Please, could you add to this doc section
https://labelstud.io/guide/tasks.html#Import-data-from-a-local-directory
a task example with the correct path to file (and maybe some note about /data/local-files/ path), like:

```
{
"data": {
"image": "/data/local-files/1.jpg"
}
}

Hi!
For Local files storage you have to use /data/local-files/1.png.

Hi, I tried your suggestion but failed again as below.
e

I want to know the requirement of setting the local path while adding the source storage. It is the absolute path of starting from the home directory as below.
d

Hi,

Isn't it suppose to be /data/local-files/?d=1.png
Or am i misunderstanding something

@makseq @li3cmz

@Morgadoooo yes, of course. You are right!

Hi!
For Local files storage you have to use /data/local-files/1.png.

Hi, I tried your suggestion but failed again as below.
e

I want to know the requirement of setting the local path while adding the source storage. It is the absolute path of starting from the home directory as below.
d

Hi, if i'm not mistaking i got this info from : core.settings.base

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

So i think you can probably specify path regarding this info of BASE_DIR

Edit :
Nvm I misunderstood it
here is the code for get_data for local files (label_studio/io_storages/localfiles/models.py) :

document_root = Path(get_env('LOCAL_FILES_DOCUMENT_ROOT', default='/'))
relative_path = str(path.relative_to(document_root))

so regarding this :
If you didn't define a LABEL_STUDIO_LOCAL_FILES_DOCUMENT_ROOT env variable the base path will be /

Hi, if i'm not mistaking, I think that there maybe some inappropriate and misleading codes for get_data.

Maybe the environment variable LOCAL_FILES_DOCUMENT_ROOT should be replaced by self.path which is received from the Label Studio UI. And then we don't have to set the LOCAL_FILES_DOCUMENT_ROOT again.

At first I thought that there was no need to set LOCAL_FILES_DOCUMENT_ROOT again after setting Local path in the UI of Edit Source Storage, which caused the error that I mentioned above.

And the error appeared after I set the variable use_blob_urls to be true as the screenshot shown below.
WXWorkCapture_16185623512878

Maybe the problem could be solved by more specific documentation for LOCAL_FILES_DOCUMENT_ROOT or changing the code.

@li3cmz Did you manage to import local files without errors?
What did you change in the initial example?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

fakyras picture fakyras  路  3Comments

lfgogogo picture lfgogogo  路  3Comments

makseq picture makseq  路  6Comments

dalekube picture dalekube  路  3Comments

cverluise picture cverluise  路  3Comments