AI 换装之OOTDiffusion

项目地址:https://github.com/levihsu/OOTDiffusion
试用地址:https://ootd.ibot.cn/
其它项目

本地部署

下载模型

方式1

  1. git lfs安装, 然后国内源下载 git clone https://www.modelscope.cn/AI-ModelScope/clip-vit-large-patch14.git
  2. 然后国内镜像手动下载 https://hf-mirror.com/levihsu/OOTDiffusion/tree/main 相应模型文件(git 好像访问不到)
  3. 将模型文件放到项目checkpints下

方式2

代码下载

import os
os.environ["HF_ENDPOINT"] = "https://hf-mirror.com"  # 设置为hf的国内镜像网站

from huggingface_hub import snapshot_download

model_name = "bert-base-uncased"
# while True 是为了防止断联
save_dir = "./models"
while True:
    try:
        snapshot_download(
            repo_id=model_name,
            # local_dir_use_symlinks=True,  # 在local-dir指定的目录中都是一些“链接文件”
            ignore_patterns=["*.bin"],  # 忽略下载哪些文件
            local_dir=save_dir,
            # token="*************",   # huggingface的token
            resume_download=True
        )
        break
    except:
        print("******************************************************************")
        print("Download failed, retrying...")
        pass

代码修改

由于只有一个GPU,文件run\gradio_ootd.py中#24~#26原来为:
openpose_model_dc = OpenPose(1)
parsing_model_dc = Parsing(1)
ootd_model_dc = OOTDiffusionDC(1)
把它们改成:
openpose_model_dc = openpose_model_hd
parsing_model_dc = parsing_model_hd
ootd_model_dc = ootd_model_hd

代码运行

  1. 指定图片运行 python3 run_ootd.py --model_path ren.png --cloth_path clothes2.jpg --scale 2.0 --sample 4
  2. 网页demo运行 python3 gradio_ootd.py

原理解析

简介

基于图片虚拟试穿(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将其与目标人体融合。

前置内容

  1. clip-vit-large-patch14
  2. Stable Diffusion v1.5
  3. VAE

原理

在这里插入图片描述

  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. 去噪后,特征映射被解码回图像空间作为我们的试戴结果。
  • 4
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

AICVer

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值