Skip to content

Repository files navigation

MyFit

CI Build

image

I wanted a safe and private way to see how clothes will fit with my existing wardrobe before buying them online, so I quickly put this together to run on my 3090.

Virtual try-on functionality powered by IDM-VTON.

Features

  • Async job queue for GPU inference
  • Prometheus metrics and OpenTelemetry tracing
  • Kubernetes-ready health probes
  • Request correlation IDs
  • Structured JSON logging
  • NixOS module and Docker deployment

Requirements

  • NVIDIA GPU with CUDA support
  • ~12GB VRAM (float16) or ~24GB VRAM (float32)
  • Python 3.11+ or Nix/Docker

Quick Start

Docker

# Standard (requires nvidia-container-runtime)
docker run --gpus all -p 8000:8000 ghcr.io/clairesrc/myfit:latest

# NixOS (uses CDI)
docker run --device nvidia.com/gpu=all -p 8000:8000 ghcr.io/clairesrc/myfit:latest

Nix

nix develop  # Enter dev shell
python -m myfit.api.main --host 0.0.0.0

pip

pip install -e ".[all]"
python -m myfit.api.main

The API is available at http://localhost:8000 with docs at /docs.

API

Submit Try-On

curl -X POST http://localhost:8000/tryon \
  -F "person_image=@person.jpg" \
  -F "garment_image=@garment.jpg" \
  -F "seed=42"

Returns {"job_id": "...", "status": "pending"}.

Check Status

curl http://localhost:8000/tryon/{job_id}

Status: pendingprocessingcompleted | failed

Download Result

curl -o result.png http://localhost:8000/result/{job_id}

Health Probes

Endpoint Purpose
GET /health Comprehensive status with GPU/disk info
GET /health/ready Readiness probe (models loaded?)
GET /health/live Liveness probe (process alive?)
GET /metrics Prometheus metrics

Configuration

All settings use the MYFIT_ prefix:

Variable Default Description
MYFIT_HOST 127.0.0.1 Bind address
MYFIT_PORT 8000 Server port
MYFIT_DEVICE cuda cuda or cpu
MYFIT_PRECISION float16 float16 or float32
MYFIT_RESULT_PATH /tmp/myfit-results Result storage
MYFIT_LOG_LEVEL INFO DEBUG, INFO, WARNING, ERROR
MYFIT_LOG_FORMAT text text or json
MYFIT_METRICS_ENABLED true Enable /metrics endpoint
MYFIT_TRACING_ENABLED false Enable OpenTelemetry
MYFIT_OTLP_ENDPOINT OTLP exporter endpoint
MYFIT_FRONTEND_ENABLED true Enable web UI

Deployment

Kubernetes

kubectl apply -f k8s/

Includes Deployment with GPU resources, readiness/liveness probes, ConfigMap, Service, and Ingress.

NixOS

{
  inputs.myfit.url = "github:clairesrc/myfit";

  outputs = { self, nixpkgs, myfit, ... }: {
    nixosConfigurations.host = nixpkgs.lib.nixosSystem {
      modules = [
        myfit.nixosModules.default
        {
          services.myfit = {
            enable = true;
            host = "0.0.0.0";
            openFirewall = true;
          };
        }
      ];
    };
  };
}

Development

nix develop           # Enter dev shell
pytest tests/ -v      # Run tests
ruff check myfit/     # Lint
mypy myfit/           # Type check
pre-commit install    # Setup git hooks

CI/CD

GitHub Actions runs on every push:

  • Lint: ruff check + format
  • Type check: mypy
  • Test: pytest with coverage
  • Security: Trivy vulnerability scan
  • Build: Docker image to GHCR (main branch)

License

MIT. The IDM-VTON model weights are licensed under CC BY-NC-SA 4.0 and are downloaded separately at runtime.

About

virtual try-on web API

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages