Home

Awesome

<p align="center"> <h2 align="center">AnyDoor: Zero-shot Object-level Image Customization</h2> <p align="center"> <a href="https://xavierchen34.github.io/"><strong>Xi Chen</strong></a> · <a href="https://scholar.google.com/citations?user=JYVCn3AAAAAJ&hl=en"><strong>Lianghua Huang</strong></a> · <a href="https://scholar.google.com/citations?user=8zksQb4AAAAJ&hl=zh-CN"><strong>Yu Liu</strong></a> · <a href="https://shenyujun.github.io/"><strong>Yujun Shen</strong></a> · <a href="https://scholar.google.com/citations?user=7LhjCn0AAAAJ&hl=en"><strong>Deli Zhao</strong></a> · <a href="https://hszhao.github.io/"><strong>Hengshuang Zhao</strong></a> <br> <br> <a href="https://arxiv.org/abs/2307.09481"><img src='https://img.shields.io/badge/arXiv-AnyDoor-red' alt='Paper PDF'></a> <a href='https://ali-vilab.github.io/AnyDoor-Page/'><img src='https://img.shields.io/badge/Project_Page-AnyDoor-green' alt='Project Page'></a> <a href='https://modelscope.cn/studios/damo/AnyDoor-online/summary'><img src='https://img.shields.io/badge/ModelScope-AnyDoor-yellow'></a> <a href='https://huggingface.co/spaces/xichenhku/AnyDoor-online'><img src='https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Spaces-blue'></a> <a href='https://replicate.com/lucataco/anydoor'><img src='https://replicate.com/lucataco/anydoor/badge'></a> <br> <b>The University of Hong Kong &nbsp; | &nbsp; Alibaba Group | &nbsp; Ant Group </b> </p> <table align="center"> <tr> <td> <img src="assets/Figures/Teaser.png"> </td> </tr> </table>

News

Installation

Install with conda:

conda env create -f environment.yaml
conda activate anydoor

or pip:

pip install -r requirements.txt

Additionally, for training, you need to install panopticapi, pycocotools, and lvis-api.

pip install git+https://github.com/cocodataset/panopticapi.git

pip install pycocotools -i https://pypi.douban.com/simple

pip install lvis

Automatic installation for Windows

Clone this git:

git clone https://github.com/sdbds/AnyDoor-for-windows

Right click on install.ps1 and Run with PowerShell. Run GUI with run_gui.ps1

Manual installation for Windows

Open CMD and clone repository:

git clone https://github.com/sdbds/AnyDoor-for-windows

Create venv, activate it and upgrade pip:

cd AnyDoor-for-windows
python -m venv venv
venv\Scripts\Activate
python.exe -m pip install --upgrade pip

Install requirements:

pip install -r requirements-windows.txt

Install torch with CUDA:

pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118

Install xformers for CUDA:

pip3 install -U xformers --index-url https://download.pytorch.org/whl/cu118

Create path folder inside AnyDoor-for-windows folder, and download all models to the path folder!

Run the demo GUI after venv has been activated:

python run_gradio_demo.py

Download Checkpoints

Download AnyDoor checkpoint:

Note: We include all the optimizer params for Adam, so the checkpoint is big. You could only keep the "state_dict" to make it much smaller.

Download DINOv2 checkpoint and revise /configs/anydoor.yaml for the path (line 83)

Download Stable Diffusion V2.1 if you want to train from scratch.

Inference

We provide inference code in run_inference.py (from Line 222 - ) for both inference single image and inference a dataset (VITON-HD Test). You should modify the data path and run the following code. The generated results are provided in examples/TestDreamBooth/GEN for single image, and VITONGEN for VITON-HD Test.

python run_inference.py

The inferenced results on VITON-Test would be like [garment, ground truth, generation].

Noticing that AnyDoor does not contain any specific design/tuning for tryon, we think it would be helpful to add skeleton infos or warped garment, and tune on tryon data to make it better :)

<table align="center"> <tr> <td> <img src="assets/Figures/tryon.png"> </td> </tr> </table>

Our evaluation data for DreamBooth an COCOEE coud be downloaded at Google Drive:

Gradio demo

Currently, we suport local gradio demo. To launch it, you should firstly modify /configs/demo.yaml for the path to the pretrained model, and /configs/anydoor.yaml for the path to DINOv2(line 83).

Afterwards, run the script:

python run_gradio_demo.py

The gradio demo would look like the UI shown below:

<table align="center"> <tr> <td> <img src="assets/Figures/gradio.png"> </td> </tr> </table>

Train

Prepare datasets

Prepare initial weight

sh ./scripts/convert_weight.sh  

Start training

sh ./scripts/train.sh  

🔥 Community Contributions

@bdsqlsz

Acknowledgements

This project is developped on the codebase of ControlNet. We appreciate this great work!

Citation

If you find this codebase useful for your research, please use the following entry.

@article{chen2023anydoor,
  title={Anydoor: Zero-shot object-level image customization},
  author={Chen, Xi and Huang, Lianghua and Liu, Yu and Shen, Yujun and Zhao, Deli and Zhao, Hengshuang},
  journal={arXiv preprint arXiv:2307.09481},
  year={2023}
}