diff --git a/label_studio_ml/examples/yolo_sam2_tracker/Dockerfile b/label_studio_ml/examples/yolo_sam2_tracker/Dockerfile index 033a3263..5b844bf6 100644 --- a/label_studio_ml/examples/yolo_sam2_tracker/Dockerfile +++ b/label_studio_ml/examples/yolo_sam2_tracker/Dockerfile @@ -29,9 +29,6 @@ ENV PYTHONUNBUFFERED=1 \ SEGMENT_ANYTHING_2_REPO_PATH=/segment-anything-2 \ PYTHONPATH=/app -# Install CUDA toolkit via Conda -RUN conda install -c "nvidia/label/cuda-12.1.1" cuda -y - # Install Python dependencies COPY requirements-base.txt . RUN --mount=type=cache,target=${PIP_CACHE_DIR},sharing=locked \ @@ -48,26 +45,38 @@ RUN --mount=type=cache,target=${PIP_CACHE_DIR},sharing=locked \ pip install -e . RUN cd checkpoints && ./download_ckpts.sh +# Clone and install label-studio-ml-backend +WORKDIR /app +RUN git clone https://github.com/HumanSignal/label-studio-ml-backend.git \ + && cd label-studio-ml-backend/ \ + && pip install -e . + # Return to app working directory WORKDIR /app # Install test dependencies (optional) COPY requirements-test.txt . -RUN --mount=type=cache,target=${PIP_CACHE_DIR},sharing=locked \ - if [ "$TEST_ENV" = "true" ]; then \ +RUN if [ "$TEST_ENV" = "true" ]; then \ pip install -r requirements-test.txt; \ + else \ + echo "Skipping test dependencies installation"; \ fi -# Download YOLO models -RUN /bin/sh -c 'if [ ! -f /app/models/yolov8m.pt ]; then \ +# Download YOLO models (only if the image exists) +RUN /bin/sh -c 'if [ -f /app/tests/car.jpg ]; then \ yolo predict model=/app/models/yolov8m.pt source=/app/tests/car.jpg \ && yolo predict model=/app/models/yolov8n.pt source=/app/tests/car.jpg \ && yolo predict model=/app/models/yolov8n-cls.pt source=/app/tests/car.jpg \ && yolo predict model=/app/models/yolov8n-seg.pt source=/app/tests/car.jpg; \ + else \ + echo "Image not found, skipping YOLO model tests"; \ fi' # Copy app files COPY . ./ +# Ensure the script has executable permissions +RUN chmod +x /app/start.sh + # Default command CMD ["/app/start.sh"] diff --git a/label_studio_ml/examples/yolo_sam2_tracker/docker-compose.yml b/label_studio_ml/examples/yolo_sam2_tracker/docker-compose.yml index 7647bf39..a9caeeca 100644 --- a/label_studio_ml/examples/yolo_sam2_tracker/docker-compose.yml +++ b/label_studio_ml/examples/yolo_sam2_tracker/docker-compose.yml @@ -1,9 +1,9 @@ version: "3.8" services: - MOT_yolo_sam: - container_name: MOT_yolo_sam - image: humansignal/MOT_yolo_sam:v0 + MOT_yolo_sam_tracker: + container_name: MOT_yolo_sam_tracker + image: humansignal/mot_yolo_sam_tracker:v0 build: context: . args: @@ -20,7 +20,7 @@ services: - BASIC_AUTH_USER= - BASIC_AUTH_PASS= # set the log level for the model server - - LOG_LEVEL=DEBUG + - LOG_LEVEL=INFO # 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 @@ -32,6 +32,7 @@ services: - DEVICE=cuda # or 'cpu' (coming soon) # SAM2 model config - MODEL_CONFIG=./configs/sam2.1/sam2.1_hiera_l.yaml + - SEGMENT_ANYTHING_2_REPO_PATH=./sam2 # SAM2 checkpoint - MODEL_CHECKPOINT=sam2.1_hiera_large.pt - MAX_FRAMES_TO_TRACK=2000 diff --git a/label_studio_ml/examples/yolo_sam2_tracker/requirements.txt b/label_studio_ml/examples/yolo_sam2_tracker/requirements.txt index eb032f3b..0be850c0 100644 --- a/label_studio_ml/examples/yolo_sam2_tracker/requirements.txt +++ b/label_studio_ml/examples/yolo_sam2_tracker/requirements.txt @@ -1,5 +1,8 @@ -ultralytics~=8.2.76 -tqdm +ultralytics~=8.2.103 +tqdm~=4.67.1 torchmetrics~=1.4.2 opencv-python -cuda-python \ No newline at end of file +cuda-python +av~=14.0.1 +numpy~=1.24.4 +pycocotools~=2.0.8 \ No newline at end of file diff --git a/label_studio_ml/examples/yolo_sam2_tracker/start.sh b/label_studio_ml/examples/yolo_sam2_tracker/start.sh index fb947619..5589b314 100644 --- a/label_studio_ml/examples/yolo_sam2_tracker/start.sh +++ b/label_studio_ml/examples/yolo_sam2_tracker/start.sh @@ -1,9 +1,5 @@ #!/bin/bash -# Export environment variables -export LABEL_STUDIO_URL= -export LABEL_STUDIO_API_KEY= -export LOG_LEVEL="DEBUG" # Start the label-studio-ml backend -label-studio-ml start ./../yolo_sam2_tracker +exec gunicorn --bind :${PORT:-9090} --workers ${WORKERS:-1} --threads ${THREADS:-4} --timeout 0 _wsgi:app diff --git a/label_studio_ml/examples/yolo_sam2_tracker/tests/__init__.py b/label_studio_ml/examples/yolo_sam2_tracker/tests/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/label_studio_ml/examples/yolo_sam2_tracker/tests/car.jpg b/label_studio_ml/examples/yolo_sam2_tracker/tests/car.jpg new file mode 100644 index 00000000..5b170064 Binary files /dev/null and b/label_studio_ml/examples/yolo_sam2_tracker/tests/car.jpg differ