# PromptGallery-stable-diffusion-webui
**Repository Path**: dbscholar0/PromptGallery-stable-diffusion-webui
## Basic Information
- **Project Name**: PromptGallery-stable-diffusion-webui
- **Description**: 使用您的角色的提示构建一个yaml文件,点击生成,然后通过它们的单词属性和修饰符快速预览。
- **Primary Language**: Unknown
- **License**: Apache-2.0
- **Default Branch**: main
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2023-04-08
- **Last Updated**: 2023-04-08
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
[![Forks][forks-shield]][forks-url]
[![Stargazers][stars-shield]][stars-url]
[![Issues][issues-shield]][issues-url]
Table of Contents
-
About The Project
-
Getting Started
-
Usage
- Contributing
- Contact
- Acknowledgments
## About The Project
TLDR; Stable-diffusion is an AI model which can generate illustration based on text-based prompts. What does a prompt/prompt-set in AI's eyes? How do we do prompt combination like shopping?
This is an extension of [stable-diffusion-webui](https://github.com/AUTOMATIC1111/stable-diffusion-webui). Checkout this powerful tool.
Use Prompt Gallery like a cookbook. Build your own prompt-set library and do illustration/creation. Life is that easy.
> Please star the repo if you likes it :>
## Cool Features:
* Scalable Prompt Library
* Stable-Diffusion-WebUI Integration
* Avatar System (model/character presets)
Keep your pace. Let's start from building your prompt library. Build Library
(back to top)
### Built With
* [![Vue][Vue.js]][Vue-url]
* [![JavaScript][JSP]][JSP-url]
* Gradio
* [![Pytorch][Pytorch]][Pytorch-url]
* [![React][fastapi-img]][fastapi-url]
(back to top)
## Getting Started
> 🐘 Good news: we now adapt to webui dark theme.
### Prerequisites & Installation
Make sure you cloned the [stable-diffusion-webui](https://github.com/AUTOMATIC1111/stable-diffusion-webui) before. If not check out [stable-diffusion-webui](https://github.com/AUTOMATIC1111/stable-diffusion-webui) to install it first.
-> Below is very important, otherwise "send to webui button will be not functional"
**Make sure you add "--api --listen --cors-allow-origins http://localhost:5173" as "COMMANDLINE_ARGS" in webui-user.bat like this**
**If you start webui manually please also make sure you add these parameters to launch.py**
**If using customized webui/ ip and port please refer to cuatomized ip and port**

Follow instructions on [stable-diffusion-webui](https://github.com/AUTOMATIC1111/stable-diffusion-webui) to start webui
Goto Tab extensions in the webui and paste:
1. paste https://github.com/dr413677671/PromptGallery-stable-diffusion-webui.git into textbox "URL for extension's git repository"
2. Set Local directory name as "Prompt Gallery"

(back to top)
## Customized extension ip and port
If you need to customized the ip of this extension.
Search %extension-path%\assets\index.*.js, change "127.0.0.1" into your extension ip
Search %extension-path%\scripts\prompt_gallery.py change
"""python
pg_ip = "%your_extension_ip%" if shared.cmd_opts.listen else 'localhost'
pg_port = %your_extension_port%
"""
Change webui param to --cors-allow-origins http://%extension-ip%:%extension-port% --api --server-name %webui-ip%
### Customized webui IP and port
If your webui executed on customized ip and port. The ip and port should be detected automatically. If not, please try:
Search %extension-path%\scripts\prompt_gallery.py change
"""python
remote_webui = '%webui_ip%'
if shared.cmd_opts.server_name:
remote_webui = str(shared.cmd_opts.server_name)
port = "%webui_port%"
"""
## Usage
After installation, try restart webui. You should see a initial frontpage like this.

There is no preview pictures. Prompt Gallery works like a framework. You need to generate your own prompt-set library.
Please follow the instructions below to build your own prompt-set library: instead you could watch the video tutorial:
View Demo
Don't be afraid to build the library. There are some cool repo help you browse the prompts.
E.g. If you love anime, goto github and search "tags" or "prompts".
You will see many cool repos like [sd-danbooru-tags](https://github.com/Vetchems/sd-danbooru-tags) or [DeepDanbooru](https://github.com/KichangKim/DeepDanbooru).
### Build library
Build up the prompt-set library and character library.
| value | negative | param |
| :-----| ----: | :----: |
| Positive prompts | Negative prompts | Other params for webui image generation |
Edit the teamplate at /extensions/your-prompt-gallery-extension-name/assets/avatars.yaml, and customize your avatars with prompts.
Teamplate:
```yaml
whiteHair:
value: "1 girl, blush, White hair, Red eyes, animal ears, looking at viewer, gothic lolita, dramatic angle, very beautiful, beautiful eyes, "
negative: ""
pinkGirl:
value: "petite, 1girl, solo, pink hair, very long hair, school uniform, happy,outdoors, flower field, excited"
```
See the teamplate at /extensions/your-prompt-gallery-extension-name/assets/tags.yaml, and create your own prompt-set library.
Categorized your prompt-set Hierarchyly. For example you can create tags.yaml like this:
```yaml
Figure:
Hair:
"ponny-tail":
value: "ponny-tail"
negative: "lowres, bad anatomy, bad hands, text, error, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality, "
value: "short_hair"
negative: "long_hair,lowres, bad anatomy, bad hands, text, error, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality, "
Background:
'':
simple background:
value: simple background
sunburst background:
value: sunburst background
Nature:
Space:
value: "space background, space,"
Startrails:
value: colorful startrails
Woods:
value: "Woods background, fantacy background,"
```
Or do something like setup the webui parameters in "param":
```yaml
Style:
General Effect:
"General_ice_high_res":
value: "flowing ice, portrait, focus on face, complex, extremely detailed , elegant, CG, (an extremely delicate and beautiful girl), incredibly absurdres, best quality,concept art"
negative: "lowres, bad anatomy, bad hands, text, error, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality, "
param: "Steps: 30, Sampler: Euler, CFG scale: 11.5, Seed: 1058629707, Size: 512x768, Variation seed: 1692844643, Variation seed strength: 0.27, Seed resize from: 1088x512"
Background:
'':
simple background:
value: simple background
sunburst background:
value: sunburst background
Nature:
Space:
value: "space background, space,"
Startrails:
value: colorful startrails
```
### Start Prompt Gallery
Refresh webui.
Slect tab "Prompt Gallery" on top navigation bar.
You should see your prompts in prompt-gallery.
Select avatar (model for demo) -> Select prompt-sets -> Click "send WebUI"

Checkout the downloaded Images

But just the prompt-set is not enough. Let's generate preview picture for them.
### Populate previews and QC
For instance having added two new prompt-sets, there will be no preview pictures for them.

Goto tab "txt2img" and Select "Prompt Gallery" in tab "scripts"

Upload yaml library of avatar first and select avatar.

Add default prompts or default negative (prompt or negative prompt attach to each prompt-set), and upload prompt-set yaml library.
If you dont want to skip the prompt-set whose preview is already generated -> Uncheck "skip exists".

Wait for stable-diffusion-webui generate previews automatically.

Pick the best image for preview.

Reflesh. Check it out in Prompt Gallery.

You could always inspect you pictures manually in prompt-gallery-directory/assets/preview/
(back to top)
### Cutomize default image generation parameters
Edit webui-directory/extension/prompt-gallery-extension-name/paste_this_to_webui_scripts_folder/prompt_gallery.py
You should see the customize setup at the top:
```python
BATCH_SIZE = 4
N_ITER = 2
STEPS = 30
CFG_SCALE = 11.5
WIDTH = 512
HEIGHT = 768
SAMPLER_INDEX = 1
RESTORE_FACE = 'true'
TILING = 'false'
DO_NOT_SAVE_GRID = 'false'
```
Change the params if you need.
## 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**.
(back to top)
## Talk with me
* dr413677671 - [@zhihu-Calcifer](https://www.zhihu.com/people/kumonoue) - 413677671@qq.com
* Project Link: [https://github.com/dr413677671/PromptGallery-stable-diffusion-webui](https://github.com/dr413677671/PromptGallery-stable-diffusion-webui)
(back to top)
## Acknowledgments
* [stable-diffusion-webui](https://github.com/AUTOMATIC1111/stable-diffusion-webui)
* [novelai-tag](https://github.com/blacktunes/novelai-tag)
* [Gradio](https://github.com/gradio-app/gradio)
(back to top)
[contributors-shield]: https://img.shields.io/github/contributors/dr413677671/PromptGallery-stable-diffusion-webui.svg?style=for-the-badge
[contributors-url]: https://github.com/dr413677671/PromptGallery-stable-diffusion-webui/graphs/contributors
[forks-shield]: https://img.shields.io/github/forks/dr413677671/PromptGallery-stable-diffusion-webui.svg?style=for-the-badge
[forks-url]: https://github.com/dr413677671/PromptGallery-stable-diffusion-webui/network/members
[stars-shield]: https://img.shields.io/github/stars/dr413677671/PromptGallery-stable-diffusion-webui.svg?style=for-the-badge
[stars-url]: https://github.com/dr413677671/PromptGallery-stable-diffusion-webui/stargazers
[issues-shield]: https://img.shields.io/github/issues/dr413677671/PromptGallery-stable-diffusion-webui.svg?style=for-the-badge
[issues-url]: https://github.com/dr413677671/PromptGallery-stable-diffusion-webui/issues
[product-screenshot]: images/screenshot.png
[Vue.js]: https://img.shields.io/badge/Vue.js-35495E?style=for-the-badge&logo=vuedotjs&logoColor=4FC08D
[Vue-url]: https://vuejs.org/
[JSP]: https://img.shields.io/badge/JavaScript-323330?style=for-the-badge&logo=javascript&logoColor=F7DF1E
[JSP-url]: https://github.com/TheAlgorithms/JavaScript
[python-img]: https://img.shields.io/badge/Python-FFD43B?style=for-the-badge&logo=python&logoColor=blue
[python-url]: https://www.python.org/
[fastapi-img]: https://img.shields.io/badge/fastapi-109989?style=for-the-badge&logo=FASTAPI&logoColor=white
[fastapi-url]: https://fastapi.tiangolo.com/
[Pytorch]: https://img.shields.io/badge/PyTorch-EE4C2C?style=for-the-badge&logo=PyTorch&logoColor=white
[Pytorch-url]: https://github.com/pytorch/pytorch