Back to Case Studies

Diffusion-Based Virtual Try-On

Garment Transfer onto Real Photos with a Pose and Segmentation Pipeline

PrototypeFashion & BeautyRetail & E-commerceApr 2024 – Jun 2024Computer Vision & Document Intelligence
4 models
Pose, surface, parsing, segmentation
30–40 s
Generation time per image
POC
Working demo with a web interface
2 people
Me as lead, plus one developer

My Role

Role
Lead & architect
Independent consulting
Team
Me + 1 developer
Stage reached
POC with web demo
Key decisions
  • OOTDiffusion as the try-on generator
  • Four-model preprocessing: pose, surface, parsing, masks

Approach at a Glance

Details
  1. 1Generator: OOTDiffusion
  2. 2Pose and Body Understanding
  3. 3Regions and Masks
  4. 4Demo and Packaging
  5. 5Performance Finding

Executive Summary

A proof of concept for virtual try-on: take a photo of a person and a photo of a garment, and generate a realistic image of that person wearing it. For online fashion, this is the "fitting room" that product photos can't provide.

I chose OOTDiffusion, a diffusion-based try-on model, as the generator and designed the preprocessing pipeline that prepares its inputs. A good try-on needs to know exactly where the body is, how it's posed and which pixels belong to the clothing being replaced. Four models produce those inputs:

  • OpenPose for body keypoints;
  • DensePose for the body surface;
  • human parsing for body parts and clothing regions;
  • Segment Anything for precise masks.

The POC runs behind a Gradio web interface in Docker. Results looked convincing, but generation took 30–40 seconds per image, which made it clear what a production version would need to solve. I led the project as architect, with one developer.


Context

Virtual try-on is hard because the generated image has to keep everything right at once:

  • The person: their face, body shape, pose and the parts of the outfit that aren't changing.
  • The garment: its fit, folds and texture, and details like prints and logos.
  • The boundary between them: sleeves, collars and hems, where the new garment meets the body and the background.

Earlier warping-based approaches often blur textures or distort the garment. Diffusion models produce more realistic images, but only if they get precise guidance about pose and regions.


Technical Approach

  1. Generator: OOTDiffusion – I chose OOTDiffusion, a latent-diffusion try-on model that conditions generation on the garment image, as the core of the pipeline.

  2. Pose and Body Understanding – OpenPose finds body keypoints, and DensePose (on detectron2) maps the visible body surface, so the garment follows the person's pose.

  3. Regions and Masks – Human parsing labels body parts and clothing, and Segment Anything refines the masks, defining exactly which area the new garment replaces and which must stay untouched.

  4. Demo and Packaging – A Gradio interface for uploading a person and a garment, with the whole pipeline and its model weights packaged in Docker images so the demo runs reproducibly.

  5. Performance Finding – End-to-end generation took 30–40 seconds per image on the POC setup. For production, that points to faster sampling, a lighter preprocessing stack or caching of the person's preprocessing between garments.


Earlier: Tattoo Try-On Prototype (Jan 2024)

Before this POC, I built a paid prototype of the same "see it on your body" idea for tattoos, working with one engineer. It used classic computer vision in OpenCV, with no generative model:

  • a skin mask in HSV colour space finds the body area;
  • the tattoo is warped onto the largest body contour;
  • its brightness is matched to the skin;
  • it is blended with a softened alpha edge, so it reads as ink rather than a sticker.

A small desktop app let the user load a body photo and a tattoo, drag and resize the tattoo, and save the result. It worked on backs, legs, hands and torsos.


Outcome

The POC showed that realistic garment transfer onto real photos was achievable with a diffusion model guided by pose and segmentation, and it was demonstrated through a web interface. It also gave a clear answer on the main blocker for production: at 30–40 seconds per image, generation speed would have to come down before try-on could be offered live to shoppers.

Technologies

Generative AIDiffusion ModelsOOTDiffusionDensePoseOpenPoseHuman ParsingSegment AnythingGradioDocker

Planning something similar?

Tell me about it on a short call. New projects can start within 2 weeks