# Computer Vision Pipeline

> CV pipeline with Label Studio for annotation, MinIO storage, and Triton inference server

- Category: AI & Machine Learning
- Difficulty: advanced
- Components: label-studio, triton, minio, postgres
- Tags: computer-vision, label-studio, triton, annotation, inference, ml
- Source: https://docker.recipes/ai-ml/computer-vision-pipeline

## Overview

Label Studio is an open-source data labeling platform developed by Heartex that provides a web-based interface for annotating various types of data including images, text, audio, and video. Originally created to address the bottleneck of manual data annotation in machine learning workflows, Label Studio supports over 60 different labeling templates and can handle complex annotation tasks like object detection, semantic segmentation, and multi-class classification with customizable labeling interfaces.

This computer vision pipeline combines Label Studio's annotation capabilities with MinIO's S3-compatible object storage for scalable data management and NVIDIA Triton Inference Server for high-performance model serving. The stack creates a complete MLOps workflow where raw images are stored in MinIO buckets, annotated through Label Studio's web interface, and the resulting trained models are deployed via Triton for real-time inference. PostgreSQL handles Label Studio's metadata, user management, and annotation storage, ensuring data integrity throughout the annotation process.

This configuration is ideal for computer vision teams, AI startups, and research organizations that need to process large volumes of visual data while maintaining control over their annotation pipeline and model deployment infrastructure. The combination provides enterprise-grade performance and scalability without the vendor lock-in of cloud-based annotation services, making it particularly valuable for organizations with strict data governance requirements or those working with sensitive visual data.

## Features

- Label Studio's flexible annotation interface with support for bounding boxes, polygons, keypoints, and semantic segmentation for computer vision tasks
- MinIO S3-compatible storage with erasure coding and encryption for secure management of large image datasets and model artifacts
- NVIDIA Triton Inference Server with GPU acceleration supporting TensorRT, PyTorch, TensorFlow, and ONNX model formats
- PostgreSQL backend for Label Studio providing ACID compliance for annotation data and support for complex queries on labeling statistics
- Label Studio's export functionality generating annotations in COCO, YOLO, Pascal VOC, and other popular computer vision formats
- Triton's dynamic batching and model versioning capabilities for A/B testing different computer vision model iterations
- MinIO's bucket lifecycle policies for automated data archival and cost optimization of training datasets
- Label Studio's collaborative annotation features with user roles, task assignment, and annotation quality control workflows

## Use cases

- Autonomous vehicle companies building training datasets for object detection and semantic segmentation models
- Medical imaging organizations annotating radiological scans, pathology slides, and diagnostic images for AI-assisted diagnosis
- Retail and e-commerce platforms creating product image classification and visual search training data
- Security and surveillance companies developing person detection, behavior analysis, and anomaly detection systems
- Manufacturing quality control teams training computer vision models for defect detection and automated inspection
- Agricultural technology companies building crop monitoring and disease detection models from drone and satellite imagery
- Sports analytics organizations annotating player movements, ball tracking, and game event detection in video footage

## Prerequisites

- NVIDIA GPU with CUDA support and nvidia-docker runtime installed for Triton inference server acceleration
- Minimum 8GB RAM recommended (2GB for MinIO, 1GB for PostgreSQL, 2GB for Label Studio, 3GB+ for Triton with models)
- Docker Compose version 3.8+ with GPU support and familiarity with NVIDIA Container Toolkit configuration
- Understanding of computer vision model formats (ONNX, TensorRT, PyTorch) and Triton model repository structure
- Basic knowledge of S3 API and MinIO bucket policies for managing training data and model artifact storage
- Familiarity with Label Studio's labeling templates and annotation export formats for computer vision workflows

## docker-compose.yml

```yaml
services:
  label-studio:
    image: heartexlabs/label-studio:latest
    container_name: label-studio
    restart: unless-stopped
    ports:
      - "${LABEL_STUDIO_PORT:-8080}:8080"
    environment:
      - DJANGO_DB=default
      - POSTGRE_NAME=labelstudio
      - POSTGRE_USER=labelstudio
      - POSTGRE_PASSWORD=${DB_PASSWORD}
      - POSTGRE_HOST=label-studio-db
      - POSTGRE_PORT=5432
      - LABEL_STUDIO_LOCAL_FILES_SERVING_ENABLED=true
      - LABEL_STUDIO_LOCAL_FILES_DOCUMENT_ROOT=/label-studio/files
    volumes:
      - label_studio_data:/label-studio/data
      - ./files:/label-studio/files
    depends_on:
      - label-studio-db

  label-studio-db:
    image: postgres:15-alpine
    container_name: label-studio-db
    restart: unless-stopped
    environment:
      - POSTGRES_USER=labelstudio
      - POSTGRES_PASSWORD=${DB_PASSWORD}
      - POSTGRES_DB=labelstudio
    volumes:
      - label_studio_db_data:/var/lib/postgresql/data

  minio:
    image: minio/minio:latest
    container_name: cv-minio
    restart: unless-stopped
    ports:
      - "${MINIO_PORT:-9000}:9000"
      - "${MINIO_CONSOLE:-9001}:9001"
    environment:
      - MINIO_ROOT_USER=${MINIO_ACCESS_KEY}
      - MINIO_ROOT_PASSWORD=${MINIO_SECRET_KEY}
    volumes:
      - minio_data:/data
    command: server /data --console-address ":9001"

  triton:
    image: nvcr.io/nvidia/tritonserver:latest
    container_name: triton
    restart: unless-stopped
    ports:
      - "${TRITON_HTTP:-8000}:8000"
      - "${TRITON_GRPC:-8001}:8001"
      - "${TRITON_METRICS:-8002}:8002"
    volumes:
      - ./models:/models
    command: tritonserver --model-repository=/models
    deploy:
      resources:
        reservations:
          devices:
            - driver: nvidia
              count: all
              capabilities: [gpu]

volumes:
  label_studio_data:
  label_studio_db_data:
  minio_data:
```

## .env

```bash
# Computer Vision Pipeline
LABEL_STUDIO_PORT=8080
MINIO_PORT=9000
MINIO_CONSOLE=9001
TRITON_HTTP=8000
TRITON_GRPC=8001
TRITON_METRICS=8002

# Database
DB_PASSWORD=labelstudio_password

# MinIO
MINIO_ACCESS_KEY=minioadmin
MINIO_SECRET_KEY=minioadmin
```

## Usage notes

- Label Studio at http://localhost:8080 (create account)
- MinIO Console at http://localhost:9001
- Triton inference at localhost:8000 (HTTP), 8001 (gRPC)
- Place models in ./models with Triton config.pbtxt
- Label Studio exports annotations for training
- Triton serves trained models for inference

## Troubleshooting

- Label Studio 'Database connection failed' error: Ensure PostgreSQL container is fully started before Label Studio by adding health checks or increasing startup delay
- Triton 'No models available' message: Verify model repository structure with config.pbtxt files and correct model format in ./models directory
- MinIO 'Access Denied' errors: Check MINIO_ACCESS_KEY and MINIO_SECRET_KEY environment variables match client configuration and bucket policies
- Label Studio annotation exports timing out: Increase Django timeout settings and ensure sufficient disk space in label_studio_data volume
- Triton GPU memory errors: Monitor nvidia-smi output and adjust model instance counts or batch sizes in model configuration files
- PostgreSQL connection pool exhaustion: Increase max_connections in PostgreSQL configuration or implement connection pooling for high-volume annotation workloads

