Home

Awesome

<div id="top"></div> <!-- *** Thanks for checking out the Best-README-Template. If you have a suggestion *** that would make this better, please fork the repo and create a pull request *** or simply open an issue with the tag "enhancement". *** Don't forget to give the project a star! *** Thanks again! Now go create something AMAZING! :D --> <!-- PROJECT SHIELDS --> <!-- *** I'm using markdown "reference style" links for readability. *** Reference links are enclosed in brackets [ ] instead of parentheses ( ). *** See the bottom of this document for the declaration of the reference variables *** for contributors-url, forks-url, etc. This is an optional, concise syntax you may use. *** https://www.markdownguide.org/basic-syntax/#reference-style-links --> <!-- [![Contributors][contributors-shield]][contributors-url] [![Forks][forks-shield]][forks-url] [![Stargazers][stars-shield]][stars-url] [![Issues][issues-shield]][issues-url] [![MIT License][license-shield]][license-url] [![LinkedIn][linkedin-shield]][linkedin-url] --> <!-- PROJECT LOGO --> <br /> <!-- <div align="center"> <a href="https://github.com/othneildrew/Best-README-Template"> <img src="images/logo.png" alt="Logo" width="80" height="80"> </a> <h3 align="center">Best-README-Template</h3> <p align="center"> An awesome README template to jumpstart your projects! <br /> <a href="https://github.com/othneildrew/Best-README-Template"><strong>Explore the docs »</strong></a> <br /> <br /> <a href="https://github.com/othneildrew/Best-README-Template">View Demo</a> · <a href="https://github.com/othneildrew/Best-README-Template/issues">Report Bug</a> · <a href="https://github.com/othneildrew/Best-README-Template/issues">Request Feature</a> </p> </div> --> <!-- TABLE OF CONTENTS --> <!-- <details> <summary>Table of Contents</summary> <ol> <li> <a href="#about-the-project">CAST</a> <ul> <li><a href="#built-with">Built With</a></li> </ul> </li> <li> <a href="#getting-started">Getting Started</a> <ul> <li><a href="#prerequisites">Prerequisites</a></li> <li><a href="#installation">Installation</a></li> </ul> </li> <li><a href="#usage">Usage</a></li> <li><a href="#roadmap">Roadmap</a></li> <li><a href="#contributing">Contributing</a></li> <li><a href="#license">License</a></li> <li><a href="#contact">Contact</a></li> <li><a href="#acknowledgments">Acknowledgments</a></li> </ol> </details> --> <!-- ABOUT THE PROJECT -->

Inversion-Based Style Transfer with Diffusion Models

<!-- ![teaser](./Images/teaser.png) -->

teaser

The artistic style within a painting is the means of expression, which includes not only the painting material, colors, and brushstrokes, but also the high-level attributes including semantic elements, object shapes, etc. Previous arbitrary example-guided artistic image generation methods often fail to control shape changes or convey elements. The pre-trained text-to-image synthesis diffusion probabilistic models have achieved remarkable quality, but it often requires extensive textual descriptions to accurately portray attributes of a particular painting. We believe that the uniqueness of an artwork lies precisely in the fact that it cannot be adequately explained with normal language.Our key idea is to learn artistic style directly from a single painting and then guide the synthesis without providing complex textual descriptions. Specifically, we assume style as a learnable textual description of a painting. We propose an inversion-based style transfer method (InST), which can efficiently and accurately learn the key information of an image, thus capturing and transferring the complete artistic style of a painting. We demonstrate the quality and efficiency of our method on numerous paintings of various artists and styles.

For details see the paper

News

📣📣 Received some requirements, therefore we have added an optional AdaIN module in InST.ipynb to help you achieve results that better meet your needs.

📣📣 See our latest work about attribute-aware image generation with diffusion model ProSpect: Expanded Conditioning for the Personalization of Attribute-aware Image Generation in Code.

<p align="right">(<a href="#top">back to top</a>)</p> <!-- ### Built With --> <!-- This section should list any major frameworks/libraries used to bootstrap your project. Leave any add-ons/plugins for the acknowledgements section. Here are a few examples. * [Next.js](https://nextjs.org/) * [React.js](https://reactjs.org/) * [Vue.js](https://vuejs.org/) * [Angular](https://angular.io/) * [Svelte](https://svelte.dev/) * [Laravel](https://laravel.com) * [Bootstrap](https://getbootstrap.com) * [JQuery](https://jquery.com) <p align="right">(<a href="#top">back to top</a>)</p> --> <!-- GETTING STARTED -->

Getting Started

Prerequisites

For packages, see environment.yaml.

conda env create -f environment.yaml
conda activate ldm
<p align="right">(<a href="#top">back to top</a>)</p>

Installation

Clone the repo

git clone https://github.com/zyxElsa/InST.git
<p align="right">(<a href="#top">back to top</a>)</p>

Train

Train InST:

python main.py --base configs/stable-diffusion/v1-finetune.yaml
            -t 
            --actual_resume ./models/sd/sd-v1-4.ckpt
            -n <run_name> 
            --gpus 0, 
            --data_root /path/to/directory/with/images

See configs/stable-diffusion/v1-finetune.yaml for more options

Download the pretrained Stable Diffusion Model and save it at ./models/sd/sd-v1-4.ckpt.

<p align="right">(<a href="#top">back to top</a>)</p>

Test

To generate new images, run InST.ipynb

<p align="right">(<a href="#top">back to top</a>)</p>

Comparison Data

For a easier comparison with InST, the results generated with the same random seed seed=50 and similar strength without any cherry-picking are supplemented. You can download the embedding.pt and content/style/results images here.

<!-- ![comparison_data](./Images/comparison_data.png) -->

comparison_data

<p align="right">(<a href="#top">back to top</a>)</p>

Citation

@InProceedings{Zhang_2023_inst,
 author    = {Zhang, Yuxin and Huang, Nisha and Tang, Fan and Huang, Haibin and Ma, Chongyang and Dong, Weiming and Xu, Changsheng},
 title     = {Inversion-Based Style Transfer With Diffusion Models},
 booktitle = {Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)},
 month     = {June},
 year      = {2023},
 pages     = {10146-10156}
}
<p align="right">(<a href="#top">back to top</a>)</p> <!-- <!-- USAGE EXAMPLES --> <!-- ## Usage Use this space to show useful examples of how a project can be used. Additional screenshots, code examples and demos work well in this space. You may also link to more resources. _For more examples, please refer to the [Documentation](https://example.com)_ <p align="right">(<a href="#top">back to top</a>)</p> --> <!-- ROADMAP --> <!-- ## Roadmap - [x] Add Changelog - [x] Add back to top links - [ ] Add Additional Templates w/ Examples - [ ] Add "components" document to easily copy & paste sections of the readme - [ ] Multi-language Support - [ ] Chinese - [ ] Spanish See the [open issues](https://github.com/othneildrew/Best-README-Template/issues) for a full list of proposed features (and known issues). <p align="right">(<a href="#top">back to top</a>)</p> --> <!-- CONTRIBUTING --> <!-- ## Contributing --> <!-- Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**. If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again! 1. Fork the Project 2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`) 3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`) 4. Push to the Branch (`git push origin feature/AmazingFeature`) 5. Open a Pull Request --> <!-- <p align="right">(<a href="#top">back to top</a>)</p> --> <!-- LICENSE --> <!-- ## License --> <!-- Distributed under the MIT License. See `LICENSE.txt` for more information. --> <!-- <p align="right">(<a href="#top">back to top</a>)</p> --> <!-- CONTACT -->

Contact

Please feel free to open an issue or contact us personally if you have questions, need help, or need explanations. Write to one of the following email addresses, and maybe put one other in the cc:

zhangyuxin2020@ia.ac.cn

<!-- Your Name - [@your_twitter](https://twitter.com/your_username) - email@example.com Project Link: [https://github.com/your_username/repo_name](https://github.com/your_username/repo_name) --> <p align="right">(<a href="#top">back to top</a>)</p> <!-- ACKNOWLEDGMENTS --> <!-- ## Acknowledgments --> <!-- Use this space to list resources you find helpful and would like to give credit to. I've included a few of my favorites to kick things off! * [Choose an Open Source License](https://choosealicense.com) * [GitHub Emoji Cheat Sheet](https://www.webpagefx.com/tools/emoji-cheat-sheet) * [Malven's Flexbox Cheatsheet](https://flexbox.malven.co/) * [Malven's Grid Cheatsheet](https://grid.malven.co/) * [Img Shields](https://shields.io) * [GitHub Pages](https://pages.github.com) * [Font Awesome](https://fontawesome.com) * [React Icons](https://react-icons.github.io/react-icons/search) --> <!-- <p align="right">(<a href="#top">back to top</a>)</p> --> <!-- MARKDOWN LINKS & IMAGES --> <!-- https://www.markdownguide.org/basic-syntax/#reference-style-links -->