Skip to content

401 error when accessing the image from label studio #848

@s1n7ax

Description

@s1n7ax

I'm using Yolo example docker-compose here. From what I can see, yolo is trying to get the image from label studio without providing the token which result in 401 response.

[yolo] | [2025-12-24 11:36:05,285] [DEBUG] [label_studio_ml.model::build_label_map::404] Model Labels <=> Label Studio Labels:
[yolo] | {'person': 'person'}
[yolo] | [2025-12-24 11:36:05,285] [DEBUG] [model::detect_control_models::83] Control tag with model detected: RectangleLabels from_name=label, label_map={'person': 'person'}, model_score_threshold=0.25
[yolo] | [2025-12-24 11:36:05,285] [DEBUG] [label_studio_sdk._extensions.label_studio_tools.core.utils.io::get_local_path::121] get_local_path() called with the following arguments:
[yolo] |   url: /data/local-files/?d=clips/front_road-1766067698.629039-oipxw5-clean.png
[yolo] |   cache_dir: None
[yolo] |   project_dir: None
[yolo] |   hostname: None
[yolo] |   image_dir: None
[yolo] |   access_token: None
[yolo] |   download_resources: True
[yolo] |   task_id: 11944
[yolo] | [2025-12-24 11:36:05,285] [DEBUG] [label_studio_sdk._extensions.label_studio_tools.core.utils.io::get_local_path::188] Image and upload dirs: image_dir=/root/.local/share/label-studio/media/upload, upload_dir=/root/.local/share
/label-studio/media/upload
[yolo] | [2025-12-24 11:36:05,285] [INFO] [label_studio_sdk._extensions.label_studio_tools.core.utils.io::get_local_path::241] Resolving url using hostname [http://label-studio:8080]: http://label-studio:8080/data/local-files/?d=clips/f
ront_road-1766067698.629039-oipxw5-clean.png
[yolo] | [2025-12-24 11:36:05,287] [DEBUG] [urllib3.connectionpool::_new_conn::241] Starting new HTTP connection (1): label-studio:8080
[yolo] | [2025-12-24 11:36:05,295] [DEBUG] [urllib3.connectionpool::_make_request::544] http://label-studio:8080 "GET /data/local-files/?d=clips/front_road-1766067698.629039-oipxw5-clean.png HTTP/1.1" 401 155
[yolo] | [2025-12-24 11:36:05,295] [ERROR] [label_studio_ml.exceptions::exception_f::53] Traceback (most recent call last):
[yolo] |   File "/opt/conda/lib/python3.10/site-packages/label_studio_ml/exceptions.py", line 39, in exception_f
[yolo] |     return f(*args, **kwargs)
[yolo] |   File "/opt/conda/lib/python3.10/site-packages/label_studio_ml/api.py", line 69, in _predict
[yolo] |     response = model.predict(tasks, context=context, **params)
[yolo] |   File "/app/model.py", line 116, in predict
[yolo] |     path = model.get_path(task)
[yolo] |   File "/app/control_models/base.py", line 187, in get_path
[yolo] |     else get_local_path(task_path, task_id=task.get("id"))
[yolo] |   File "/opt/conda/lib/python3.10/site-packages/label_studio_sdk/_extensions/label_studio_tools/core/utils/io.py", line 274, in get_local_path
[yolo] |     filepath = download_and_cache(
[yolo] |   File "/opt/conda/lib/python3.10/site-packages/label_studio_sdk/_extensions/label_studio_tools/core/utils/io.py", line 340, in download_and_cache
[yolo] |     raise e
[yolo] |   File "/opt/conda/lib/python3.10/site-packages/label_studio_sdk/_extensions/label_studio_tools/core/utils/io.py", line 329, in download_and_cache
[yolo] |     r.raise_for_status()
[yolo] |   File "/opt/conda/lib/python3.10/site-packages/requests/models.py", line 1026, in raise_for_status
[yolo] |     raise HTTPError(http_error_msg, response=self)
[yolo] | requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: http://label-studio:8080/data/local-files/?d=clips/front_road-1766067698.629039-oipxw5-clean.png
[yolo] | 
[yolo] | Traceback (most recent call last):
[yolo] |   File "/opt/conda/lib/python3.10/site-packages/label_studio_ml/exceptions.py", line 39, in exception_f
[yolo] |     return f(*args, **kwargs)
[yolo] |   File "/opt/conda/lib/python3.10/site-packages/label_studio_ml/api.py", line 69, in _predict
[yolo] |     response = model.predict(tasks, context=context, **params)
[yolo] |   File "/app/model.py", line 116, in predict
[yolo] |     path = model.get_path(task)
[yolo] |   File "/app/control_models/base.py", line 187, in get_path
[yolo] |     else get_local_path(task_path, task_id=task.get("id"))
[yolo] |   File "/opt/conda/lib/python3.10/site-packages/label_studio_sdk/_extensions/label_studio_tools/core/utils/io.py", line 274, in get_local_path
[yolo] |     filepath = download_and_cache(
[yolo] |   File "/opt/conda/lib/python3.10/site-packages/label_studio_sdk/_extensions/label_studio_tools/core/utils/io.py", line 340, in download_and_cache
[yolo] |     raise e
[yolo] |   File "/opt/conda/lib/python3.10/site-packages/label_studio_sdk/_extensions/label_studio_tools/core/utils/io.py", line 329, in download_and_cache
[yolo] |     r.raise_for_status()
[yolo] |   File "/opt/conda/lib/python3.10/site-packages/requests/models.py", line 1026, in raise_for_status
[yolo] |     raise HTTPError(http_error_msg, response=self)
[yolo] | requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: http://label-studio:8080/data/local-files/?d=clips/front_road-1766067698.629039-oipxw5-clean.png
[yolo] | 
[yolo] | [2025-12-24 11:36:05,296] [DEBUG] [label_studio_ml.api::log_response_info::191] Response status: 500 INTERNAL SERVER ERROR
[yolo] | [2025-12-24 11:36:05,296] [DEBUG] [label_studio_ml.api::log_response_info::192] Response headers: Content-Type: application/json
[yolo] | Content-Length: 1599
[yolo] | 
[yolo] | 
[yolo] | [2025-12-24 11:36:05,296] [DEBUG] [label_studio_ml.api::log_response_info::193] Response body: b'{"detail":"HTTPError: 401 Client Error: Unauthorized for url: http://label-studio:8080/data/local-files/?d=clips/front_road-176606
7698.629039-oipxw5-clean.png","request":{},"result":{"traceback":"Traceback (most recent call last):\\n  File \\"/opt/conda/lib/python3.10/site-packages/label_studio_ml/exceptions.py\\", line 39, in exception_f\\n    return f(*args, **k
wargs)\\n  File \\"/opt/conda/lib/python3.10/site-packages/label_studio_ml/api.py\\", line 69, in _predict\\n    response = model.predict(tasks, context=context, **params)\\n  File \\"/app/model.py\\", line 116, in predict\\n    path = 
model.get_path(task)\\n  File \\"/app/control_models/base.py\\", line 187, in get_path\\n    else get_local_path(task_path, task_id=task.get(\\"id\\"))\\n  File \\"/opt/conda/lib/python3.10/site-packages/label_studio_sdk/_extensions/lab
el_studio_tools/core/utils/io.py\\", line 274, in get_local_path\\n    filepath = download_and_cache(\\n  File \\"/opt/conda/lib/python3.10/site-packages/label_studio_sdk/_extensions/label_studio_tools/core/utils/io.py\\", line 340, in 
download_and_cache\\n    raise e\\n  File \\"/opt/conda/lib/python3.10/site-packages/label_studio_sdk/_extensions/label_studio_tools/core/utils/io.py\\", line 329, in download_and_cache\\n    r.raise_for_status()\\n  File \\"/opt/conda/
lib/python3.10/site-packages/requests/models.py\\", line 1026, in raise_for_status\\n    raise HTTPError(http_error_msg, response=self)\\nrequests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: http://label-studio:8080/da
ta/local-files/?d=clips/front_road-1766067698.629039-oipxw5-clean.png\\n"},"status":500}\n'

I'm running the yolo container in the same network and label studio created a successful connection with the model. However when I try "Test Request", I see above logs.

version: "3.8"

services:
  yolo:
    container_name: yolo
    image: humansignal/yolo:v0
    build:
      context: .
      args:
        TEST_ENV: ${TEST_ENV}
    environment:
      # specify these parameters if you want to use basic auth for the model server
      - BASIC_AUTH_USER=
      - BASIC_AUTH_PASS=
      # set the log level for the model server
      - LOG_LEVEL=DEBUG
      # any other parameters that you want to pass to the model server
      - ANY=PARAMETER
      # specify the number of workers and threads for the model server
      - WORKERS=1
      - THREADS=8
      # specify the model directory (likely you don't need to change this)
      - MODEL_DIR=/data/models
      - PYTHONPATH=/app

      # Specify the Label Studio URL and API key to access
      # uploaded, local storage and cloud storage files.
      # Do not use 'localhost' or '127.0.0.1' as it does not work within Docker containers.
      # Use prefix 'http://' or 'https://' for the URL always.
      # Determine the actual IP using 'ifconfig' (Linux/Mac) or 'ipconfig' (Windows).
      # or you can try http://host.docker.internal:<label-studio-port> if you run LS on the same machine
      - LABEL_STUDIO_HOST=http://label-studio:8080
      - LABEL_STUDIO_API_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0b2tlbl90eXBlIjoicmVmcmVzaCIsImV4cCI6ODA3Mzc3NTU1NCwiaWF0IjoxNzY2NTc1NTU0LCJqdGkiOiJlZWEyOWQxZDkxYTg0NTZjOTEyMGUwMmM0OWJlOTI2YyIsInVzZXJfaWQiOiIxIn0.trJU5eCSuoq5TaXSFF81s8Dc5eHLeYIMY1m1ZUDtjvM

      # YOLO parameters

      # Allow to use custom `model_path` in labeling configurations
      - ALLOW_CUSTOM_MODEL_PATH=true
      # Show matplotlib debug plot for YOLO predictions
      - DEBUG_PLOT=false
      # Default score threshold, which is used to filter out low-confidence predictions,
      # you can change it in the labeling configuration using `model_score_threshold` parameter in the control tags
      - MODEL_SCORE_THRESHOLD=0.5
      # Model root directory, where the YOLO model files are stored
      - MODEL_ROOT=/app/models
    extra_hosts:
      - "host.docker.internal:host-gateway" # for macos and unix
    ports:
      - "9090:9090"
    volumes:
      - "./data/server:/data"
      - "./models:/app/models"
      - "./cache_dir:/app/cache_dir"
    networks:
      - shared

networks:
  shared:
    name: shared

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions