# vivocameraresearch/magic-tryon architecture

> Architecture diagram of the GitHub repository vivocameraresearch/magic-tryon, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/vivocameraresearch/magic-tryon
- Repository: https://github.com/vivocameraresearch/magic-tryon

## Overview

MagicTryOn generates garment-preserving virtual try-on images and videos with Wan diffusion models; its documented customization workflow prepares garment line art and person-alignment inputs before video inference. The graph includes the standard and Turbo inference branches, plus the API/UI and reward functionality visible in the tree. Some preprocessing stages are documented but their implementation files are absent from the supplied tree, so they are not represented as repository nodes; edges reflect README statements or source-index references.

Main entry points: [`magic_tryon/pipeline/pipeline_wan_tryon.py`](https://github.com/vivocameraresearch/magic-tryon/blob/main/magic_tryon/pipeline/pipeline_wan_tryon.py) (Try-on pipeline), [`inference/image_tryon/predict_image_tryon_low.py`](https://github.com/vivocameraresearch/magic-tryon/blob/main/inference/image_tryon/predict_image_tryon_low.py) (Image inference), [`inference/video_tryon/predict_video_tryon_customize.py`](https://github.com/vivocameraresearch/magic-tryon/blob/main/inference/video_tryon/predict_video_tryon_customize.py) (Custom video inference), [`turbo_inference/bidirectional_inference_vivid.py`](https://github.com/vivocameraresearch/magic-tryon/blob/main/turbo_inference/bidirectional_inference_vivid.py) (Turbo inference)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_inputs["Try-on Inputs"]
  node_garment["Garment image"]
  node_person["Person media"]
  node_lineart["Garment line art<br/>[infer.py]"]
  node_densepose["DensePose alignment"]
end

subgraph group_standard["Standard Generation"]
  node_image_entry["Image inference"]
  node_video_entry["Video inference"]
  node_custom_entry["Custom video inference"]
  node_pipeline["Try-on pipeline"]
  node_transformer["Try-on transformer"]
  node_model_components["Wan model components<br/>[__init__.py]"]
  node_lora["LoRA utilities<br/>[lora_utils.py]"]
end

subgraph group_turbo["Turbo Generation"]
  node_turbo_entry["Turbo inference"]
  node_turbo_inference["Bidirectional inference"]
  node_trajectory["Trajectory wrapper"]
  node_turbo_models["Turbo model components"]
  node_turbo_inpaint["Turbo inpainting"]
end

subgraph group_product["Product Interfaces"]
  node_api["API<br/>[api.py]"]
  node_ui["UI controller<br/>[controller.py]"]
  node_reward["Reward scoring<br/>[reward_fn.py]"]
end

node_user(("Try-on user"))
node_result["Generated try-on"]

node_user -->|"supplies"| node_garment
node_user -->|"supplies"| node_person
node_garment -->|"extracts lines"| node_lineart
node_person -->|"aligns body"| node_densepose
node_user -->|"requests image"| node_image_entry
node_user -->|"requests video"| node_video_entry
node_user -->|"requests custom video"| node_custom_entry
node_lineart -->|"conditions try-on"| node_custom_entry
node_densepose -->|"aligns try-on"| node_custom_entry
node_image_entry -->|"invokes"| node_pipeline
node_video_entry -->|"invokes"| node_pipeline
node_custom_entry -->|"invokes"| node_pipeline
node_pipeline -->|"uses"| node_transformer
node_pipeline -->|"uses"| node_model_components
node_image_entry -->|"loads"| node_transformer
node_image_entry -->|"uses"| node_lora
node_pipeline -->|"generates"| node_result
node_user -->|"requests turbo"| node_turbo_entry
node_turbo_entry -->|"constructs"| node_turbo_inference
node_turbo_inference -->|"uses"| node_turbo_models
node_trajectory -.->|"calls generator"| node_turbo_models
node_turbo_inpaint -->|"uses"| node_turbo_models
node_turbo_entry -->|"writes video"| node_result
node_user -.->|"uses"| node_api
node_user -.->|"uses"| node_ui
node_ui -.->|"produces samples"| node_result
node_reward -.->|"scores outputs"| node_result

click node_lineart "https://github.com/vivocameraresearch/magic-tryon/blob/main/inference/customize/AniLines/infer.py"
click node_densepose "https://github.com/vivocameraresearch/magic-tryon/tree/main/inference/customize/detectron2/projects/DensePose"
click node_image_entry "https://github.com/vivocameraresearch/magic-tryon/blob/main/inference/image_tryon/predict_image_tryon_low.py"
click node_video_entry "https://github.com/vivocameraresearch/magic-tryon/blob/main/inference/video_tryon/predict_video_tryon_up.py"
click node_custom_entry "https://github.com/vivocameraresearch/magic-tryon/blob/main/inference/video_tryon/predict_video_tryon_customize.py"
click node_pipeline "https://github.com/vivocameraresearch/magic-tryon/blob/main/magic_tryon/pipeline/pipeline_wan_tryon.py"
click node_transformer "https://github.com/vivocameraresearch/magic-tryon/blob/main/magic_tryon/models/wan_transformer3d_tryon.py"
click node_model_components "https://github.com/vivocameraresearch/magic-tryon/blob/main/magic_tryon/models/__init__.py"
click node_lora "https://github.com/vivocameraresearch/magic-tryon/blob/main/magic_tryon/utils/lora_utils.py"
click node_turbo_entry "https://github.com/vivocameraresearch/magic-tryon/blob/main/turbo_inference/bidirectional_inference_vivid.py"
click node_turbo_inference "https://github.com/vivocameraresearch/magic-tryon/blob/main/magictryon_turbo/models/wan/bidirectional_inference.py"
click node_trajectory "https://github.com/vivocameraresearch/magic-tryon/blob/main/magictryon_turbo/bidirectional_trajectory_pipeline.py"
click node_turbo_models "https://github.com/vivocameraresearch/magic-tryon/blob/main/magictryon_turbo/models/wan/videox_fun/models/wan_image_encoder.py"
click node_turbo_inpaint "https://github.com/vivocameraresearch/magic-tryon/blob/main/magictryon_turbo/models/wan/videox_fun/pipeline/pipeline_cogvideox_fun_inpaint.py"
click node_api "https://github.com/vivocameraresearch/magic-tryon/blob/main/magic_tryon/api/api.py"
click node_ui "https://github.com/vivocameraresearch/magic-tryon/blob/main/magic_tryon/ui/controller.py"
click node_reward "https://github.com/vivocameraresearch/magic-tryon/blob/main/magic_tryon/reward/reward_fn.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_garment,node_person,node_lineart,node_densepose,node_user toneBlue
class node_image_entry,node_video_entry,node_custom_entry,node_pipeline,node_transformer,node_model_components,node_lora toneAmber
class node_turbo_entry,node_turbo_inference,node_trajectory,node_turbo_models,node_turbo_inpaint toneMint
class node_api,node_ui,node_reward toneRose
class node_result toneIndigo
```

## Components

### Try-on Inputs

- **Garment image**
- **Person media**
- [Garment line art](https://github.com/vivocameraresearch/magic-tryon/blob/main/inference/customize/AniLines/infer.py): `inference/customize/AniLines/infer.py`
- [DensePose alignment](https://github.com/vivocameraresearch/magic-tryon/tree/main/inference/customize/detectron2/projects/DensePose): `inference/customize/detectron2/projects/DensePose`

### Standard Generation

- [Image inference](https://github.com/vivocameraresearch/magic-tryon/blob/main/inference/image_tryon/predict_image_tryon_low.py): `inference/image_tryon/predict_image_tryon_low.py`
- [Video inference](https://github.com/vivocameraresearch/magic-tryon/blob/main/inference/video_tryon/predict_video_tryon_up.py): `inference/video_tryon/predict_video_tryon_up.py`
- [Custom video inference](https://github.com/vivocameraresearch/magic-tryon/blob/main/inference/video_tryon/predict_video_tryon_customize.py): `inference/video_tryon/predict_video_tryon_customize.py`
- [Try-on pipeline](https://github.com/vivocameraresearch/magic-tryon/blob/main/magic_tryon/pipeline/pipeline_wan_tryon.py): `magic_tryon/pipeline/pipeline_wan_tryon.py`
- [Try-on transformer](https://github.com/vivocameraresearch/magic-tryon/blob/main/magic_tryon/models/wan_transformer3d_tryon.py): `magic_tryon/models/wan_transformer3d_tryon.py`
- [Wan model components](https://github.com/vivocameraresearch/magic-tryon/blob/main/magic_tryon/models/__init__.py): `magic_tryon/models/__init__.py`
- [LoRA utilities](https://github.com/vivocameraresearch/magic-tryon/blob/main/magic_tryon/utils/lora_utils.py): `magic_tryon/utils/lora_utils.py`

### Turbo Generation

- [Turbo inference](https://github.com/vivocameraresearch/magic-tryon/blob/main/turbo_inference/bidirectional_inference_vivid.py): `turbo_inference/bidirectional_inference_vivid.py`
- [Bidirectional inference](https://github.com/vivocameraresearch/magic-tryon/blob/main/magictryon_turbo/models/wan/bidirectional_inference.py): `magictryon_turbo/models/wan/bidirectional_inference.py`
- [Trajectory wrapper](https://github.com/vivocameraresearch/magic-tryon/blob/main/magictryon_turbo/bidirectional_trajectory_pipeline.py): `magictryon_turbo/bidirectional_trajectory_pipeline.py`
- [Turbo model components](https://github.com/vivocameraresearch/magic-tryon/blob/main/magictryon_turbo/models/wan/videox_fun/models/wan_image_encoder.py): `magictryon_turbo/models/wan/videox_fun/models/wan_image_encoder.py`
- [Turbo inpainting](https://github.com/vivocameraresearch/magic-tryon/blob/main/magictryon_turbo/models/wan/videox_fun/pipeline/pipeline_cogvideox_fun_inpaint.py): `magictryon_turbo/models/wan/videox_fun/pipeline/pipeline_cogvideox_fun_inpaint.py`

### Product Interfaces

- [API](https://github.com/vivocameraresearch/magic-tryon/blob/main/magic_tryon/api/api.py): `magic_tryon/api/api.py`
- [UI controller](https://github.com/vivocameraresearch/magic-tryon/blob/main/magic_tryon/ui/controller.py): `magic_tryon/ui/controller.py`
- [Reward scoring](https://github.com/vivocameraresearch/magic-tryon/blob/main/magic_tryon/reward/reward_fn.py): `magic_tryon/reward/reward_fn.py`

### Other components

- **Try-on user**
- **Generated try-on**

## Connections

- Try-on user → Garment image: supplies
- Try-on user → Person media: supplies
- Garment image → Garment line art: extracts lines
- Person media → DensePose alignment: aligns body
- Try-on user → Image inference: requests image
- Try-on user → Video inference: requests video
- Try-on user → Custom video inference: requests custom video
- Garment line art → Custom video inference: conditions try-on
- DensePose alignment → Custom video inference: aligns try-on
- Image inference → Try-on pipeline: invokes (evidence: `inference/image_tryon/predict_image_tryon_low.py`)
- Video inference → Try-on pipeline: invokes (evidence: `inference/video_tryon/predict_video_tryon_up.py`)
- Custom video inference → Try-on pipeline: invokes
- Try-on pipeline → Try-on transformer: uses (evidence: `magic_tryon/pipeline/pipeline_wan_tryon.py`)
- Try-on pipeline → Wan model components: uses (evidence: `magic_tryon/pipeline/pipeline_wan_tryon.py`)
- Image inference → Try-on transformer: loads (evidence: `inference/image_tryon/predict_image_tryon_low.py`)
- Image inference → LoRA utilities: uses (evidence: `inference/image_tryon/predict_image_tryon_low.py`)
- Try-on pipeline → Generated try-on: generates
- Try-on user → Turbo inference: requests turbo
- Turbo inference → Bidirectional inference: constructs (evidence: `turbo_inference/bidirectional_inference_vivid.py`)
- Bidirectional inference → Turbo model components: uses (evidence: `magictryon_turbo/models/wan/bidirectional_inference.py`)
- Trajectory wrapper → Turbo model components: calls generator
- Turbo inpainting → Turbo model components: uses (evidence: `magictryon_turbo/models/wan/videox_fun/pipeline/pipeline_cogvideox_fun_inpaint.py`)
- Turbo inference → Generated try-on: writes video
- Try-on user → API: uses
- Try-on user → UI controller: uses
- UI controller → Generated try-on: produces samples
- Reward scoring → Generated try-on: scores outputs
