https://github.com/cuc-zihang-liu/blend-latent-diffusion
代码复现
Science Score: 10.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
○codemeta.json file
-
○.zenodo.json file
-
○DOI references
-
✓Academic publication links
Links to: arxiv.org -
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (15.2%) to scientific vocabulary
Last synced: 9 months ago
·
JSON representation
Repository
代码复现
Basic Info
Statistics
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
- Releases: 0
Created about 1 year ago
· Last pushed about 1 year ago
https://github.com/CUC-ZIHANG-LIU/Blend-Latent-Diffusion/blob/main/
# Blended Diffusion for Text-driven Editing of Natural Images [CVPR 2022]![]()
![]()
![]()
![]()
> **Blended Diffusion for Text-driven Editing of Natural Images** > > Omri Avrahami, Dani Lischinski, Ohad Fried > > Abstract: Natural language offers a highly intuitive interface for image editing. In this paper, we introduce the first solution for performing local (region-based) edits in generic natural images, based on a natural language description along with an ROI mask. We achieve our goal by leveraging and combining a pretrained language-image model (CLIP), to steer the edit towards a user-provided text prompt, with a denoising diffusion probabilistic model (DDPM) to generate natural-looking results. To seamlessly fuse the edited region with the unchanged parts of the image, we spatially blend noised versions of the input image with the local text-guided diffusion latent at a progression of noise levels. In addition, we show that adding augmentations to the diffusion process mitigates adversarial results. We compare against several baselines and related methods, both qualitatively and quantitatively, and show that our method outperforms these solutions in terms of overall realism, ability to preserve the background and matching the text. Finally, we show several text-driven editing applications, including adding a new object to an image, removing/replacing/altering existing objects, background replacement, and image extrapolation. # News You may be interested in the follow-up project Blended Latent Diffusion, which produces better results and with a significant speed-up. Code is available here. # Getting Started ## Installation 1. Create the virtual environment: ```bash $ conda create --name blended-diffusion python=3.9 $ conda activate blended-diffusion $ pip3 install ftfy regex matplotlib lpips kornia opencv-python torch==1.9.0+cu111 torchvision==0.10.0+cu111 -f https://download.pytorch.org/whl/torch_stable.html ``` 2. Create a `checkpoints` directory and download the pretrained diffusion model from [here](https://huggingface.co/omriav/blended-diffusion/resolve/main/checkpoints/256x256_diffusion_uncond.pt?download=true) to this folder. ## Image generation An example of text-driven multiple synthesis results: ```bash $ python main.py -p "rock" -i "input_example/img.png" --mask "input_example/mask.png" --output_path "output" ``` The generation results will be saved in `output/ranked` folder, ordered by CLIP similarity rank. In order to get the best results, please generate a large number of results (at least 64) and take the best ones. In order to generate multiple results in a single diffusion process, we utilized batch processing. If you get `CUDA out of memory` try first to lower the batch size by setting `--batch_size 1`. # Applications ### Multiple synthesis results for the same prompt
### Synthesis results for different prompts
### Altering part of an existing object
### Background replacement
![]()
### Scribble-guided editing
### Text-guided extrapolation
### Composing several applications
![]()
# Acknowledgments This code borrows from [CLIP](https://github.com/openai/CLIP), [Guided-diffusion](https://github.com/openai/guided-diffusion) and [CLIP-Guided Diffusion](https://colab.research.google.com/drive/12a_Wrfi2_gwwAuN3VvMTwVMz9TfqctNj). # Citation If you use this code for your research, please cite the following: ``` @InProceedings{Avrahami_2022_CVPR, author = {Avrahami, Omri and Lischinski, Dani and Fried, Ohad}, title = {Blended Diffusion for Text-Driven Editing of Natural Images}, booktitle = {Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)}, month = {June}, year = {2022}, pages = {18208-18218} } ```
Owner
- Name: 刘子航
- Login: CUC-ZIHANG-LIU
- Kind: user
- Company: 中国传媒大学
- Repositories: 1
- Profile: https://github.com/CUC-ZIHANG-LIU
GitHub Events
Total
- Watch event: 1
Last Year
- Watch event: 1
>
### Synthesis results for different prompts
### Altering part of an existing object
### Background replacement
### Scribble-guided editing
### Text-guided extrapolation
### Composing several applications
# Acknowledgments
This code borrows from [CLIP](https://github.com/openai/CLIP), [Guided-diffusion](https://github.com/openai/guided-diffusion) and [CLIP-Guided Diffusion](https://colab.research.google.com/drive/12a_Wrfi2_gwwAuN3VvMTwVMz9TfqctNj).
# Citation
If you use this code for your research, please cite the following:
```
@InProceedings{Avrahami_2022_CVPR,
author = {Avrahami, Omri and Lischinski, Dani and Fried, Ohad},
title = {Blended Diffusion for Text-Driven Editing of Natural Images},
booktitle = {Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)},
month = {June},
year = {2022},
pages = {18208-18218}
}
```