label-studio-ml-backend
label-studio-ml-backend copied to clipboard
FileNotFoundError: Can't resolve url, neither hostname or project_dir passed
Hello,
I set up the label studio via python (conda) on windows 10.
I try to add label studio ml backend (using docker) , using the example mmdetection.
I added it properly in UI, the server is started.
But I get an error that i don t know how to solve.
Can someone please help me to solve it?
My image are actually in this folder: C:\Users\user1\AppData\Local\label-studio\label-studio\media
FileNotFoundError: Can't resolve url, neither hostname or project_dir passed: /data/upload/3/
Traceback (most recent call last): File "/usr/local/lib/python3.7/site-packages/label_studio_ml/exceptions.py", line 39, in exception_f return f(*args, **kwargs) File "/usr/local/lib/python3.7/site-packages/label_studio_ml/api.py", line 32, in _predict predictions, model = _manager.predict(tasks, project, label_config, force_reload, try_fetch, **params) File "/usr/local/lib/python3.7/site-packages/label_studio_ml/model.py", line 584, in predict predictions = m.model.predict(tasks, **kwargs) File "./mmdetection.py", line 92, in predict image_path = self.get_local_path(image_url) File "/usr/local/lib/python3.7/site-packages/label_studio_ml/model.py", line 322, in get_local_path return get_local_path(url, project_dir=project_dir, hostname=self.hostname, access_token=self.access_token) File "/usr/local/lib/python3.7/site-packages/label_studio_tools/core/utils/io.py", line 76, in get_local_path raise FileNotFoundError("Can't resolve url, neither hostname or project_dir passed: " + url) FileNotFoundError: Can't resolve url, neither hostname or project_dir passed: /data/upload/3/698f8072-battery3.jpg
Thank s in advance for your help.
Hi @NL647 Do you have such files in your docker container with ML backend?
Hi @KonstantinKorotaev I have also encountered similar problems. I use the label studio on win10. When I use local files as "Source Storage(settings>Cloud Storage)", it raises FileNotFoundError, and it prints "FileNotFoundError: x\xxx.jpg\local-files/". When I import data using "Upload Files", it says "FileNotFoundError: Can't resolve url, neither hostname or project_dir passed: /data/upload/1/c1330d7b-xxx.jpg". It can't seem to get the image's path correctly. I don't know how to let it get the correct path or the Drive Letter. The correct path should be "F:..\dataset\image\food" or "E:\label-studio\media\upload\1\xxx.jpg". Should I need to modify the "label_studio_tools\core\utils\io.py" ?
Hi @RayAdas-GA-17 Are you running your ML backend in Docker?
Hi @KonstantinKorotaev I run it in windows 10. But now, I make it work by update the label-studio. In the new version, it gets the image path with the environment variable “LABEL_STUDIO_LOCAL_FILES_DOCUMENT_ROOT”. Thank you for your reply.
I'm having the same issue, except I'm running Label Studio from a Conda virtual env on Windows 11, and the ML backend on a WSL instance of Ubuntu because I simply cannot get the backend to run under Windows because of some WSGI error. Not sure what the issue is, but I'm not getting any OCR content, only locations when using a rectangle.
@KonstantinKorotaev I am using the ML backend inside docker but my label-studio is running from a conda environment. Do you have a workaround for such an issue?
@raash1d the most efficient solution is to mount the local storage folder to docker and slightly change the file reading in the ML backend so that it reads files from the mounted folder.
主要原因是project_dir后面不应该有‘upload’, get_local_path函数会在project_dir后面补一个upload modify label_studio_ml/model.py as following:
def get_local_path(self, url, project_dir=None):
#return get_local_path(url, project_dir=project_dir, hostname=self.hostname, access_token=self.access_token) =>
return get_local_path(url, project_dir=project_dir.replace('/upload', '/'), hostname=self.hostname, access_token=self.access_token)