OOTDiffusion环境搭建&推理测试

引子
记得2015年左右,去参加VALSE的时候,就有虚拟试衣的项目亮相。现在回头看看,当时的效果还是十分简陋和不协调的。今天在全球最大的同性交友网站github上突然发现一个不错的虚拟试衣项目,看其效果还是不错,加入了扩散模型,效果看起来有质的提升。OK,让我们开始吧。
一、模型介绍
1、简介
基于图片虚拟试穿(image-based virtual try-on ,VTON)
基于扩散模型全套试穿:Outfitting over Try-on Diffusion (OOTDiffusion)
利用预训练的潜在扩散模型的力量(pretrained latent diffusion models),用于现实和可控的(realistic and controllable)虚拟试穿。在没有明确的衣物形变适应过程(warping process)的情况下,
提出了一个outfitting UNet来学习服装细节特征,在扩散模型去噪过程中,通过我们提出的服装融合outfitting fusion将其与目标人体融合。
2、算法原理
0
(1)在左侧,服装图像被 clip-vit-large-patch14 编码到潜在空间中,并输入到服装UNet中进行单步处理。
(2)与CLIP编码器生成的辅助调节输入一起,通过服装融合(outfitting fusion)将服装特征纳入去噪UNet。
(3)在训练过程中,为了实现无分类器的指导(classifier-free guidance),对训练过程进行了 outfitting dropout。
(4)在右侧,输入的人类图像通过掩码生成模块(mask generator, HumanParsing+OpenPose )将需要换衣以及相近的地方被遮盖为黑色(masked),并与高斯噪声连接在一起,作为多个采样步骤的去噪UNet的输入。
(5)去噪后,特征映射被解码回图像空间作为我们的试戴结果。
二、环境安装
docker run -it --rm --gpus=all -v /datas/work/zzq:/workspace ootdiffusion:v1.0 bash
cd /workspace/ootdiffusion
cd ootdiffusion
pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
模型下载
cd run
三、推理测试
cd run
1、上衣替换
python run_ootd.py --model_path /workspace/ootdiffusion/OOTDiffusion/images/model_img.png --cloth_path /workspace/ootdiffusion/OOTDiffusion/images/cloth_img.png --scale 2.0 --sample 4
输出结果如下:
0

左图为代码输出结果,右图为示例输出

2、全身替换
python run_ootd.py --model_path /workspace/ootdiffusion/OOTDiffusion/images/full_body_model_img.png --cloth_path /workspace/ootdiffusion/OOTDiffusion/images/full_body_cloth_img.png --model_type dc --category 2 --scale 2.0 --sample
0

 

左图为代码输出结果,右图为示例输出
 
posted @ 2024-05-22 09:08  要养家的程序猿  阅读(190)  评论(0编辑  收藏  举报