这是论文 "Improving Diffusion Models for Authentic Virtual Try-on in the Wild"] 的官方实现。
如果你喜欢它,请给我们点个 Star ⭐!
需求
git clone https://github.com/yisol/IDM-VTON.git
cd IDM-VTON
conda env create -f environment.yaml
conda activate idm
数据准备
VITON-HD
你可以从 VITON-HD 下载 VITON-HD 数据集。
下载 VITON-HD 数据集后,将 vitonhd_test_tagged.json 移动到 test 文件夹,并将 vitonhd_train_tagged.json 移动到 train 文件夹。
数据集目录的结构应如下所示。
train
|-- image
|-- image-densepose
|-- agnostic-mask
|-- cloth
|-- vitonhd_train_tagged.json
test
|-- image
|-- image-densepose
|-- agnostic-mask
|-- cloth
|-- vitonhd_test_tagged.json
DressCode
您可以从 DressCode 下载 DressCode 数据集。
我们在 此处 提供了预计算的 densepose 图像和服装描述。
我们使用 detectron2 获取 densepose 图像,更多详情请参阅 此处。
下载 DressCode 数据集后,请按照以下方式放置 image-densepose 目录和 caption 文本文件。
DressCode
|-- dresses
|-- images
|-- image-densepose
|-- dc_caption.txt
|-- ...
|-- lower_body
|-- images
|-- image-densepose
|-- dc_caption.txt
|-- ...
|-- upper_body
|-- images
|-- image-densepose
|-- dc_caption.txt
|-- ...
训练
准备
下载预训练的 ip-adapter 用于 sdxl(IP-Adapter/sdxl_models/ip-adapter-plus_sdxl_vit-h.bin) 和图像编码器(IP-Adapter/models/image_encoder) 此处。
git clone https://huggingface.co/h94/IP-Adapter
将 ip-adapter 移动到 ckpt/ip_adapter,将 image encoder 移动到 ckpt/image_encoder。
使用带有参数的 python 文件开始训练,
accelerate launch train_xl.py \
--gradient_checkpointing --use_8bit_adam \
--output_dir=result --train_batch_size=6 \
--data_dir=DATA_DIR
或者,你可以直接通过脚本文件运行。
sh train_xl.sh
推理
VITON-HD
使用带有参数的 python 文件进行推理,
accelerate launch inference.py \
--width 768 --height 1024 --num_inference_steps 30 \
--output_dir "result" \
--unpaired \
--data_dir "DATA_DIR" \
--seed 42 \
--test_batch_size 2 \
--guidance_scale 2.0
或者,你可以直接通过脚本文件运行。
sh inference.sh
DressCode
对于 DressCode 数据集,通过 category 参数指定你想要生成图像的类别,
accelerate launch inference_dc.py \
--width 768 --height 1024 --num_inference_steps 30 \
--output_dir "result" \
--unpaired \
--data_dir "DATA_DIR" \
--seed 42
--test_batch_size 2
--guidance_scale 2.0
--category "upper_body"
或者,你可以直接运行脚本文件。
sh inference.sh
启动本地 gradio 演示 
从此处下载人体解析的 checkpoints。
将 checkpoints 放置在 ckpt 文件夹下。
ckpt
|-- densepose
|-- model_final_162be9.pkl
|-- humanparsing
|-- parsing_atr.onnx
|-- parsing_lip.onnx
|-- openpose
|-- ckpts
|-- body_pose_model.pth
运行以下命令:
python gradio_demo/app.py
致谢
感谢 ZeroGPU 提供免费的 GPU。
感谢 IP-Adapter 提供基础代码。
感谢 OOTDiffusion 和 DCI-VTON 提供掩码生成。
感谢 SCHP 提供人体分割。
感谢 Densepose 提供人体稠密姿态估计。
Star History
引用
@article{choi2024improving,
title={Improving Diffusion Models for Authentic Virtual Try-on in the Wild},
author={Choi, Yisol and Kwak, Sangkyung and Lee, Kyungmin and Choi, Hyungwon and Shin, Jinwoo},
journal={arXiv preprint arXiv:2403.05139},
year={2024}
}
许可证
本仓库中的代码和检查点遵循 CC BY-NC-SA 4.0 许可证。