Skip to content

Commit

Permalink
docker compose up working
Browse files Browse the repository at this point in the history
  • Loading branch information
adityarauniyar committed Dec 24, 2024
1 parent c736e2e commit b9b60f9
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 19 deletions.
23 changes: 16 additions & 7 deletions label_studio_ml/examples/yolo_sam2_tracker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand All @@ -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"]
9 changes: 5 additions & 4 deletions label_studio_ml/examples/yolo_sam2_tracker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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
Expand All @@ -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
Expand Down
9 changes: 6 additions & 3 deletions label_studio_ml/examples/yolo_sam2_tracker/requirements.txt
Original file line number Diff line number Diff line change
@@ -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
cuda-python
av~=14.0.1
numpy~=1.24.4
pycocotools~=2.0.8
6 changes: 1 addition & 5 deletions label_studio_ml/examples/yolo_sam2_tracker/start.sh
Original file line number Diff line number Diff line change
@@ -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
Empty file.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit b9b60f9

Please sign in to comment.