Skip to content

About

Segment a person and their clothes, then inpaint a new outfit with Stable Diffusion.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Outfit Studio

Note: This repository directory may be named clothless-next locally; the Python package and CLI are outfit-studio (outfit_studio/).

Outfit Studio logo

Fantasy clothing transformation

AI outfit inpainting for photos. Upload a person image, segment the person and clothing, optionally edit the masks, then inpaint a new outfit with Stable Diffusion.

The README demo assets are synthetic, fully clothed, and non-explicit. They show the vanilla repository path using runwayml/stable-diffusion-inpainting with ControlNet disabled.

Outfit Studio pipeline overview

What this repo does

  • Serves a Gradio UI with login, credits, examples, history, and an ImageEditor mask workflow.
  • Uses the FASHN Human Parser (SegFormer B4) to build person and clothing masks automatically.
  • Lets users repaint masks before generation, so the model changes only intended clothing regions.
  • Runs Diffusers inpainting with SD1.5, SDXL, or local .safetensors / .ckpt checkpoints.
  • Optionally adds OpenPose ControlNet guidance for SD1.5 checkpoints.
  • Saves pipeline debug artifacts for masks, crops, inpaint inputs, diffusion output, blending, metadata, and final results.

Vanilla demo

This walkthrough was produced from a fresh non-NSFW synthetic source image, then passed through the real pipeline with:

  • model: runwayml/stable-diffusion-inpainting
  • ControlNet: off
  • seed: 4242
  • steps: 24
  • prompt target: a modest, fully clothed editorial outfit

Vanilla pipeline walkthrough

The green overlay marks clothing pixels selected for inpainting; the red overlay marks the detected person area used for instance splitting and blending. Vanilla SD1.5 changes the outfit region cleanly, while custom checkpoints and ControlNet can improve style faithfulness for production use.

Useful demo files:

File Purpose
docs/assets/demo-source.png Synthetic, fully clothed input image
docs/assets/demo-mask-overlay.png Person and clothing masks from segmentation
docs/assets/demo-inpaint-input.png Crop prepared for inpainting
docs/assets/demo-diffusion-output.png Raw vanilla SD1.5 inpaint result
docs/assets/demo-blended-crop.png Feathered crop before full-frame compositing
docs/assets/demo-result-vanilla-sd15.png Final feathered full-frame blend

Debug artifacts

Add these lines to .env when you want inspectable intermediates for a run:

OUTFIT_STUDIO_PIPELINE_DEBUG=true
OUTFIT_STUDIO_PIPELINE_DEBUG_DIR=debug-pipeline

Pipeline debug artifact map

Each run creates a timestamped folder. The segmentation phase records source and fused masks; the generation phase records the final masks, per-person crop, inpaint input, diffusion output, blended crop, full composite, and JSON metadata.

Requirements

  • Python 3.10-3.12
  • uv
  • NVIDIA GPU recommended
  • 8 GB+ VRAM recommended for SD1.5 inpainting

Quick start

cp .env.example .env
make install-fast
make run

Open http://localhost:7860.

Default login:

admin / admin

make install-fast creates the virtual environment from the pinned lockfile, installs dependencies (including CUDA PyTorch and ONNX Runtime GPU support), and downloads the configured segmentation and inpaint models.

Windows

powershell -ExecutionPolicy RemoteSigned -File scripts\setup.ps1
.\.venv\Scripts\Activate.ps1
.\.venv\Scripts\python.exe -m outfit_studio.main

Reinstall CUDA torch / ORT after uv sync: scripts\install-cuda.ps1. If the console mangles box-drawing glyphs, set OUTFIT_STUDIO_ASCII_LOG=true.

Make targets

Run make (or make help) for the colored target list. NO_COLOR=1 disables ANSI.

Target Description
make / make help Show targets
make install Create .venv and install pinned Python dependencies
make install-fast Install deps from uv.lock and download models
make download-models Download segmentation weights and configured inpaint checkpoint
make run Start the Gradio UI
make stop Stop the local Gradio demo (make run)
make test Run non-slow unit tests
make lint Run Ruff
make docker-build Build the Docker image
make docker-up Start with GPU support
make docker-up-cpu Start without GPU (base compose only)
make docker-download-models Download ML weights into the running container
make docker-down Stop containers
make docker-logs Follow container logs

Docker

Requires Docker and, for GPU inference, the NVIDIA Container Toolkit.

cp .env.example .env
make docker-build
make docker-up          # GPU (compose + docker-compose.gpu.yml)
make docker-up-cpu      # CPU-only, no NVIDIA Container Toolkit
make docker-download-models   # if not bind-mounting local weights

Open http://localhost:7860. Default login (bootstrapped on first start):

admin / admin1234

Checkpoints bind-mount from ./models by default. Optional .env overrides:

  • OUTFIT_STUDIO_HOST_MODELS_DIR — host checkpoint path (use the real path if ./models is a symlink)
  • OUTFIT_STUDIO_HOST_HF_CACHE — Hugging Face hub cache (default: ~/.cache/huggingface)

Configuration

Runtime .env

Deployment settings live in .env: host, port, paths, auth, credits, logging, and pipeline debug flags.

Setting Purpose
OUTFIT_STUDIO_HOST / OUTFIT_STUDIO_PORT Server bind address
OUTFIT_STUDIO_MODELS_DIR Local model/checkpoint directory
OUTFIT_STUDIO_OUTPUT_DIR Generated image output directory
OUTFIT_STUDIO_DB_PATH SQLite database path
OUTFIT_STUDIO_REQUIRE_AUTH Login requirement
OUTFIT_STUDIO_DEFAULT_* Default admin and credit settings
OUTFIT_STUDIO_DEBUG / OUTFIT_STUDIO_LOG_LEVEL Diagnostics
OUTFIT_STUDIO_PIPELINE_DEBUG* Intermediate artifact dumps
OUTFIT_STUDIO_TENSOR_TORRENT Enable TT size-gate path (default true)
OUTFIT_STUDIO_TENSOR_TORRENT_MIN_PARAMS_GB Skip TT below this param GiB (default 4.0)
OUTFIT_STUDIO_TENSOR_TORRENT_UNET Allow UNet TT when size gate passes (default true)
OUTFIT_STUDIO_TENSOR_TORRENT_CACHE_DIR TT artifact cache (default .cache/tensortorrent)
OUTFIT_STUDIO_CIVITAI_API_TOKEN Bearer token for Civitai checkpoint downloads

Models, prompts, and generation defaults are intentionally not stored in .env.

Content and ML YAML

Branding, prompts, checkpoints, and generation tuning live in config/.

File Tracked Purpose
config/content.default.yaml Yes Vanilla defaults shipped with the repo
config/content.local.yaml No Local overrides for prompts, models, URLs, and generation tuning
config/content.local.yaml.example Yes Template for local overrides
cp config/content.local.yaml.example config/content.local.yaml

The local YAML file is merged on top of the default file. The shipped default inpaint checkpoint is runwayml/stable-diffusion-inpainting; the local example can point at custom .safetensors checkpoints and download URLs.

Stack

Component Technology
UI Gradio 4 + ImageSlider
Segmentation FASHN Human Parser (SegFormer B4)
Pose, optional rtmlib ONNX + ControlNet OpenPose
Inpainting Diffusers SD1.5 / SDXL inpaint
Oversized models TensorTorrent when params ≥ MIN_PARAMS_GB (else torch.compile)
Auth/history SQLite + Argon2

When OUTFIT_STUDIO_TENSOR_TORRENT=true (default), Outfit Studio only hands a module to TensorTorrent if its parameters are at least OUTFIT_STUDIO_TENSOR_TORRENT_MIN_PARAMS_GB (default 4.0 GiB). SD1.5 inpaint UNets (~1.7 GiB bf16) and the human parser stay on eager / torch.compile — TT's compile + schedule tax made them slower, and a resident LATENCY plan OOMs next to ControlNet on 8 GB cards. Oversized UNets (e.g. SDXL ≈4.8 GiB) use TT: text_embeds / time_ids export as plain tensors; LATENCY first, MEMORY+NVMe streaming if capacity fails. ControlNet stays eager. Pose ONNX stays outside TT. Artifacts cache under .cache/tensortorrent/.

Development

make lint
make test
pre-commit install
pre-commit run --all-files

Python entry points:

.venv/bin/outfit-studio-download-models
.venv/bin/outfit-studio

About

Segment a person and their clothes, then inpaint a new outfit with Stable Diffusion.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages