HumanSignal / HumanSignal/label-studio
FileNotFoundError using SAM on local file storage
- Dominant language
- TypeScript
- Stars
- 28.3k
- Forks
- 3.7k
- Avg merge
- 14h
- Merged PRs (30d)
- 15
Description
**Describe the bug**
FileNotFoundError is thrown when trying to annotate images that are local files and were uploaded using json. The images can be seen online and are also able to be interacted with on label studio, just not with the SAM model. However, SAM model works with images that are imported using the GUI.
Document root path: /home/user/LABELSTUDIODATA/
Local path: /home/user/LABELSTUDIODATA/images
Image can be found at: http://host:4040/data/local-files/?d=images/from_dashapp/full_seg94.png
**Details**
- Running through SSH
- Pictures are uploaded through requests.POST (which works)
- Pictures can be seen and annotated
- SAM model throws error when attempting to annotate with it on local files
- I have local files set up through "Source Cloud Storage"
- SAM model does not throw error when annotating images that were imported using GUI
samserver | [2024-03-06 22:25:57,095] [DEBUG] [sam_predictor::set_image::83] Payload not found for /data/local-files/?d=images/from_dashapp/full_seg94.png in `IN_MEM_CACHE`: calculating from scratch
samserver | [2024-03-06 22:25:57,099] [ERROR] [label_studio_ml.exceptions::exception_f::53] Traceback (most recent call last):
samserver | File "/usr/local/lib/python3.8/site-packages/label_studio_ml/exceptions.py", line 39, in exception_f
samserver | return f(*args, **kwargs)
samserver | File "/usr/local/lib/python3.8/site-packages/label_studio_ml/api.py", line 66, in _predict
samserver | response = model.predict(tasks, context=context, **params)
samserver | File "/app/model.py", line 48, in predict
samserver | predictor_results = PREDICTOR.predict(
samserver | File "/app/sam_predictor.py", line 196, in predict
samserver | return self.predict_sam(img_path, point_coords, point_labels, input_box)
samserver | File "/app/sam_predictor.py", line 168, in predict_sam
samserver | self.set_image(img_path, calculate_embeddings=False)
samserver | File "/app/sam_predictor.py", line 84, in set_image
samserver | image_path = get_image_local_path(
samserver | File "/usr/local/lib/python3.8/site-packages/label_studio_ml/utils.py", line 67, in get_image_local_path
samserver | image_local_path = get_local_path(
samserver | File "/usr/local/lib/python3.8/site-packages/label_studio_tools/core/utils/io.py", line 68, in get_local_path
samserver | raise FileNotFoundError(filepath)
samserver | FileNotFoundError: /images/from_dashapp/full_seg94.png
samserver |
samserver | Traceback (most recent call last):
samserver | File "/usr/local/lib/python3.8/site-packages/label_studio_ml/exceptions.py", line 39, in exception_f
samserver | return f(*args, **kwargs)
samserver | File "/usr/local/lib/python3.8/site-packages/label_studio_ml/api.py", line 66, in _predict
samserver | response = model.predict(tasks, context=context, **params)
samserver | File "/app/model.py", line 48, in predict
samserver | predictor_results = PREDICTOR.predict(
samserver | File "/app/sam_predictor.py", line 196, in predict
samserver | return self.predict_sam(img_path, point_coords, point_labels, input_box)
samserver | File "/app/sam_predictor.py", line 168, in predict_sam
samserver | self.set_image(img_path, calculate_embeddings=False)
samserver | File "/app/sam_predictor.py", line 84, in set_image
samserver | image_path = get_image_local_path(
samserver | File "/usr/local/lib/python3.8/site-packages/label_studio_ml/utils.py", line 67, in get_image_local_path
samserver | image_local_path = get_local_path(
samserver | File "/usr/local/lib/python3.8/site-packages/label_studio_tools/core/utils/io.py", line 68, in get_local_path
samserver | raise FileNotFoundError(filepath)
samserver | FileNotFoundError: /images/from_dashapp/full_seg94.png
samserver |
samserver | [2024-03-06 22:25:57,105] [DEBUG] [label_studio_ml.api::log_response_info::181] Response status: 500 INTERNAL SERVER ERROR
samserver | [2024-03-06 22:25:57,106] [DEBUG] [label_studio_ml.api::log_response_info::182] Response headers: Content-Type: application/json
samserver | Content-Length: 1253
samserver |
samserver |
samserver | [2024-03-06 22:25:57,106] [DEBUG] [label_studio_ml.api::log_response_info::183] Response body: b'{"detail":"FileNotFoundError: /images/from_dashapp/full_seg94.png","request":{},"result":{"traceback":"Traceback (most recent call last):\\n File \\"/usr/local/lib/python3.8/site-packages/label_studio_ml/exceptions.py\\", line 39, in exception_f\\n return f(*args, **kwargs)\\n File \\"/usr/local/lib/python3.8/site-packages/label_studio_ml/api.py\\", line 66, in _predict\\n response = model.predict(tasks, context=context, **params)\\n File \\"/app/model.py\\", line 48, in predict\\n predictor_results = PREDICTOR.predict(\\n File \\"/app/sam_predictor.py\\", line 196, in predict\\n return self.predict_sam(img_path, point_coords, point_labels, input_box)\\n File \\"/app/sam_predictor.py\\", line 168, in predict_sam\\n self.set_image(img_path, calculate_embeddings=False)\\n File \\"/app/sam_predictor.py\\", line 84, in set_image\\n image_path = get_image_local_path(\\n File \\"/usr/local/lib/python3.8/site-packages/label_studio_ml/utils.py\\", line 67, in get_image_local_path\\n image_local_path = get_local_path(\\n File \\"/usr/local/lib/python3.8/site-packages/label_studio_tools/core/utils/io.py\\", line 68, in get_local_path\\n raise FileNotFoundError(filepath)\\nFileNotFoundError: /images/from_dashapp/full_seg94.png\\n"},"status":500}\n'
Contributor guide
Assessment
This issue has not been assessed yet.