Skip to content

Import Error after successful build of YOLO ML Backend #797

@tintin-newb

Description

@tintin-newb

I was facing a dependency conflict issue while trying to deploy yolo ML backend. I solved it by changing the requirements-base.txt to the following.

gunicorn==23.0.0
label-studio-ml
label-studio-sdk
rq

I added the rq because I was getting a "ModuleNotFound" error once the build was complete and the app was deployed. This results in a successful build.

However, the app fails to run. Here's the error I am getting when I run docker compose up --build from the "yolo" directory.

$ docker compose up --build
WARN[0000] The "TEST_ENV" variable is not set. Defaulting to a blank string. 
WARN[0000] The "LABEL_STUDIO_API_KEY" variable is not set. Defaulting to a blank string. 
WARN[0000] /home/tintin/Documents/video_analytics/label-studio-ml-backend/label_studio_ml/examples/yolo/docker-compose.yml: the attribute `version` is obsolete, it will be ignored, please remove it to avoid potential confusion 
Compose can now delegate builds to bake for better performance.
 To do so, set COMPOSE_BAKE=true.
[+] Building 60.2s (19/19) FINISHED                                                                                                                            docker:default
 => [yolo internal] load build definition from Dockerfile                                                                                                                0.0s
 => => transferring dockerfile: 1.98kB                                                                                                                                   0.0s
 => [yolo internal] load metadata for docker.io/pytorch/pytorch:2.1.2-cuda12.1-cudnn8-runtime                                                                            1.0s
 => [yolo internal] load .dockerignore                                                                                                                                   0.0s
 => => transferring context: 476B                                                                                                                                        0.0s
 => [yolo stage-0  1/13] FROM docker.io/pytorch/pytorch:2.1.2-cuda12.1-cudnn8-runtime@sha256:3387e598cb94fc248d82e712a65b10931a990cea3a2e76362ca30d135f565de4            0.0s
 => [yolo internal] load build context                                                                                                                                   0.0s
 => => transferring context: 2.08kB                                                                                                                                      0.0s
 => CACHED [yolo stage-0  2/13] WORKDIR /app                                                                                                                             0.0s
 => CACHED [yolo stage-0  3/13] RUN conda update conda -y                                                                                                                0.0s
 => CACHED [yolo stage-0  4/13] RUN --mount=type=cache,target="/var/cache/apt",sharing=locked     --mount=type=cache,target="/var/lib/apt/lists",sharing=locked     apt  0.0s
 => [yolo stage-0  5/13] COPY requirements-base.txt .                                                                                                                    0.0s 
 => [yolo stage-0  6/13] RUN --mount=type=cache,target=/.cache,sharing=locked     pip install -r requirements-base.txt                                                  17.0s 
 => [yolo stage-0  7/13] COPY requirements.txt .                                                                                                                         0.0s 
 => [yolo stage-0  8/13] RUN --mount=type=cache,target=/.cache,sharing=locked     pip3 install -r requirements.txt                                                      11.4s 
 => [yolo stage-0  9/13] COPY requirements-test.txt .                                                                                                                    0.0s 
 => [yolo stage-0 10/13] RUN --mount=type=cache,target=/.cache,sharing=locked     if [ "" = "true" ]; then       pip3 install -r requirements-test.txt;     fi           0.1s 
 => [yolo stage-0 11/13] WORKDIR /app                                                                                                                                    0.0s
 => [yolo stage-0 12/13] COPY . ./                                                                                                                                       0.0s
 => [yolo stage-0 13/13] RUN /bin/sh -c 'if [ ! -f /app/models/yolov8m.pt ]; then     yolo predict model=/app/models/yolov8m.pt source=/app/tests/car.jpg     && yolo   28.6s
 => [yolo] exporting to image                                                                                                                                            2.0s
 => => exporting layers                                                                                                                                                  2.0s
 => => writing image sha256:0cd045d629210e26b7e34e2f9f6e8987ad37468a5a29e44abe4960c2abd97e15                                                                             0.0s
 => => naming to docker.io/humansignal/yolo:v0                                                                                                                           0.0s
 => [yolo] resolving provenance for metadata file                                                                                                                        0.0s
[+] Running 2/2
 ✔ yolo            Built                                                                                                                                                 0.0s 
 ✔ Container yolo  Recreated                                                                                                                                             0.0s 
Attaching to yolo
yolo  | [2025-07-11 09:29:58 +0000] [1] [INFO] Starting gunicorn 23.0.0
yolo  | [2025-07-11 09:29:58 +0000] [1] [INFO] Listening at: http://0.0.0.0:9090 (1)
yolo  | [2025-07-11 09:29:58 +0000] [1] [INFO] Using worker: gthread
yolo  | [2025-07-11 09:29:58 +0000] [7] [INFO] Booting worker with pid: 7
yolo  | [2025-07-11 09:29:59 +0000] [7] [ERROR] Exception in worker process
yolo  | Traceback (most recent call last):
yolo  |   File "/opt/conda/lib/python3.10/site-packages/gunicorn/arbiter.py", line 608, in spawn_worker
yolo  |     worker.init_process()
yolo  |   File "/opt/conda/lib/python3.10/site-packages/gunicorn/workers/gthread.py", line 94, in init_process
yolo  |     super().init_process()
yolo  |   File "/opt/conda/lib/python3.10/site-packages/gunicorn/workers/base.py", line 135, in init_process
yolo  |     self.load_wsgi()
yolo  |   File "/opt/conda/lib/python3.10/site-packages/gunicorn/workers/base.py", line 147, in load_wsgi
yolo  |     self.wsgi = self.app.wsgi()
yolo  |   File "/opt/conda/lib/python3.10/site-packages/gunicorn/app/base.py", line 66, in wsgi
yolo  |     self.callable = self.load()
yolo  |   File "/opt/conda/lib/python3.10/site-packages/gunicorn/app/wsgiapp.py", line 57, in load
yolo  |     return self.load_wsgiapp()
yolo  |   File "/opt/conda/lib/python3.10/site-packages/gunicorn/app/wsgiapp.py", line 47, in load_wsgiapp
yolo  |     return util.import_app(self.app_uri)
yolo  |   File "/opt/conda/lib/python3.10/site-packages/gunicorn/util.py", line 370, in import_app
yolo  |     mod = importlib.import_module(module)
yolo  |   File "/opt/conda/lib/python3.10/importlib/__init__.py", line 126, in import_module
yolo  |     return _bootstrap._gcd_import(name[level:], package, level)
yolo  |   File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
yolo  |   File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
yolo  |   File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
yolo  |   File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
yolo  |   File "<frozen importlib._bootstrap_external>", line 883, in exec_module
yolo  |   File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
yolo  |   File "/app/_wsgi.py", line 36, in <module>
yolo  |     from model import YOLO
yolo  |   File "/app/model.py", line 5, in <module>
yolo  |     from label_studio_ml.response import ModelResponse
yolo  | ModuleNotFoundError: No module named 'label_studio_ml.response'
yolo  | [2025-07-11 09:29:59 +0000] [7] [INFO] Worker exiting (pid: 7)
yolo  | [2025-07-11 09:29:59 +0000] [1] [ERROR] Worker (pid:7) exited with code 3
yolo  | [2025-07-11 09:29:59 +0000] [1] [ERROR] Shutting down: Master
yolo  | [2025-07-11 09:29:59 +0000] [1] [ERROR] Reason: Worker failed to boot.
yolo exited with code 3

I am following the steps as given in the readme files but still getting this issue.

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