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 -->

ArtBank: Artistic Style Transfer with Pre-trained Diffusion Model and Implicit Style Prompt Bank (AAAI2024)

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

teaser

Artistic style transfer aims to repaint the content image with the learned artistic style. Existing artistic style transfer methods can be divided into two categories: small model-based approaches and pre-trained large-scale model-based approaches. Small model-based approaches can preserve the content strucuture, but fail to produce highly realistic stylized images and introduce artifacts and disharmonious patterns; Pre-trained large-scale model-based approaches can generate highly realistic stylized images but struggle with preserving the content structure. To address the above issues, we propose ArtBank, a novel artistic style transfer framework, to generate highly realistic stylized images while preserving the content structure of the content images. Specifically, to sufficiently dig out the knowledge embedded in pre-trained large-scale models, an Implicit Style Prompt Bank (ISPB), a set of trainable parameter matrices, is designed to learn and store knowledge from the collection of artworks and behave as a visual prompt to guide pre-trained large-scale models to generate highly realistic stylized images while preserving content structure. Besides, to accelerate training the above ISPB, we propose a novel Spatial-Statistical-based self-Attention Module (SSAM). The qualitative and quantitative experiments demonstrate the superiority of our proposed method over state-of-the-art artistic style transfer methods. For details see the paper

<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/Jamie-Cheung/ArtBank.git
<p align="right">(<a href="#top">back to top</a>)</p>

Train

Train ArtBank:

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

python main.py --base configs/stable-diffusion/v1-finetune.yaml -t --actual_resume ./models/sd/sd-v1-4.ckpt -n 106 --gpus 0, --data_root ./image

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

Download the collection of artworks (https://drive.google.com/drive/folders/1_2jykbjVCF6SqJisvIt5-4fAFzVAj-F0?usp=drive_link) and put style images into ./images.

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

Test

Download the pretrained model [Artbank] (https://drive.google.com/drive/folders/1_2jykbjVCF6SqJisvIt5-4fAFzVAj-F0?usp=drive_link) You only need to change the line 177-178 with the pretrained model, then you can:

python test.py

News

We propose a new framework, called LSAST(IJCAI2024), which can generate more highly realistic artistic stylized images and preserve the content structure better. You can follow it from LSAST

<p align="right">(<a href="#top">back to top</a>)</p> <!-- ### Citation <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> -->

Citation

@inproceedings{zhang2024artbank,
title={ArtBank: Artistic Style Transfer with Pre-trained Diffusion Model and Implicit Style Prompt Bank},
author={Zhang, Zhanjie and Zhang, Quanwei and Xing, Wei and Li, Guangyuan and Zhao, Lei and Sun, Jiakai and Lan, Zehua and Luan, Junsheng and Huang, Yiling 
and Lin, Huaizhong},
booktitle={Proceedings of the AAAI Conference on Artificial Intelligence},
volume={38},
number={7},
pages={7396--7404},
year={2024}
}
<!-- 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:

cszzj@zju.edu.cn

Thank you for my co-author Quanwei Zhang

<!-- 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 -->