Text-to-Image
Diffusers
TensorBoard
Safetensors
stable-diffusion
stable-diffusion-diffusers
diffusers-training
lora
Instructions to use ButterChicken98/plantVillage-stableDiffusion-2-iter2_with_one_caption with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use ButterChicken98/plantVillage-stableDiffusion-2-iter2_with_one_caption with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-2", dtype=torch.bfloat16, device_map="cuda") pipe.load_lora_weights("ButterChicken98/plantVillage-stableDiffusion-2-iter2_with_one_caption") prompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k" image = pipe(prompt).images[0] - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- Draw Things
- DiffusionBee
File size: 7,433 Bytes
e5f5575 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | <!--Copyright 2024 The HuggingFace Team. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.
-->
# ๐งจ Diffusers ํ์ต ์์
์ด๋ฒ ์ฑํฐ์์๋ ๋ค์ํ ์ ์ฆ์ผ์ด์ค๋ค์ ๋ํ ์์ ์ฝ๋๋ค์ ํตํด ์ด๋ป๊ฒํ๋ฉด ํจ๊ณผ์ ์ผ๋ก `diffusers` ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ์ฌ์ฉํ ์ ์์๊น์ ๋ํด ์์๋ณด๋๋ก ํ๊ฒ ์ต๋๋ค.
**Note**: ํน์ ์คํผ์
ํ ์์์ฝ๋๋ฅผ ์ฐพ๊ณ ์๋ค๋ฉด, [์ฌ๊ธฐ](https://github.com/huggingface/diffusers/tree/main/src/diffusers/pipelines)๋ฅผ ์ฐธ๊ณ ํด๋ณด์ธ์!
์ฌ๊ธฐ์ ๋ค๋ฃฐ ์์๋ค์ ๋ค์์ ์งํฅํฉ๋๋ค.
- **์์ฌ์ด ๋ํ๋์ ์ค์น** (Self-contained) : ์ฌ๊ธฐ์ ์ฌ์ฉ๋ ์์ ์ฝ๋๋ค์ ๋ํ๋์ ํจํค์ง๋ค์ ์ ๋ถ `pip install` ๋ช
๋ น์ด๋ฅผ ํตํด ์ค์น ๊ฐ๋ฅํ ํจํค์ง๋ค์
๋๋ค. ๋ํ ์น์ ํ๊ฒ `requirements.txt` ํ์ผ์ ํด๋น ํจํค์ง๋ค์ด ๋ช
์๋์ด ์์ด, `pip install -r requirements.txt`๋ก ๊ฐํธํ๊ฒ ํด๋น ๋ํ๋์๋ค์ ์ค์นํ ์ ์์ต๋๋ค. ์์: [train_unconditional.py](https://github.com/huggingface/diffusers/blob/main/examples/unconditional_image_generation/train_unconditional.py), [requirements.txt](https://github.com/huggingface/diffusers/blob/main/examples/unconditional_image_generation/requirements.txt)
- **์์ฌ์ด ์์ ** (Easy-to-tweak) : ์ ํฌ๋ ๊ฐ๋ฅํ๋ฉด ๋ง์ ์ ์ฆ ์ผ์ด์ค๋ค์ ์ ๊ณตํ๊ณ ์ ํฉ๋๋ค. ํ์ง๋ง ์์๋ ๊ฒฐ๊ตญ ๊ทธ์ ์์๋ผ๋ ์ ๋ค ๊ธฐ์ตํด์ฃผ์ธ์. ์ฌ๊ธฐ์ ์ ๊ณต๋๋ ์์์ฝ๋๋ค์ ๊ทธ์ ๋จ์ํ ๋ณต์ฌ-๋ถํ๋ฃ๊ธฐํ๋ ์์ผ๋ก๋ ์ฌ๋ฌ๋ถ์ด ๋ง์ฃผํ ๋ฌธ์ ๋ค์ ์์ฝ๊ฒ ํด๊ฒฐํ ์ ์์ ๊ฒ์
๋๋ค. ๋ค์ ๋งํด ์ด๋ ์ ๋๋ ์ฌ๋ฌ๋ถ์ ์ํฉ๊ณผ ๋์ฆ์ ๋ง์ถฐ ์ฝ๋๋ฅผ ์ผ์ ๋ถ๋ถ ๊ณ ์ณ๋๊ฐ์ผ ํ ๊ฒ์
๋๋ค. ๋ฐ๋ผ์ ๋๋ถ๋ถ์ ํ์ต ์์๋ค์ ๋ฐ์ดํฐ์ ์ ์ฒ๋ฆฌ ๊ณผ์ ๊ณผ ํ์ต ๊ณผ์ ์ ๋ํ ์ฝ๋๋ค์ ํจ๊ป ์ ๊ณตํจ์ผ๋ก์จ, ์ฌ์ฉ์๊ฐ ๋์ฆ์ ๋ง๊ฒ ์์ฌ์ด ์์ ํ ์ ์๋๋ก ๋๊ณ ์์ต๋๋ค.
- **์
๋ฌธ์ ์นํ์ ์ธ** (Beginner-friendly) : ์ด๋ฒ ์ฑํฐ๋ diffusion ๋ชจ๋ธ๊ณผ `diffusers` ๋ผ์ด๋ธ๋ฌ๋ฆฌ์ ๋ํ ์ ๋ฐ์ ์ธ ์ดํด๋ฅผ ๋๊ธฐ ์ํด ์์ฑ๋์์ต๋๋ค. ๋ฐ๋ผ์ diffusion ๋ชจ๋ธ์ ๋ํ ์ต์ SOTA (state-of-the-art) ๋ฐฉ๋ฒ๋ก ๋ค ๊ฐ์ด๋ฐ์๋, ์
๋ฌธ์์๊ฒ๋ ๋ง์ด ์ด๋ ค์ธ ์ ์๋ค๊ณ ํ๋จ๋๋ฉด, ํด๋น ๋ฐฉ๋ฒ๋ก ๋ค์ ์ฌ๊ธฐ์ ๋ค๋ฃจ์ง ์์ผ๋ ค๊ณ ํฉ๋๋ค.
- **ํ๋์ ํ์คํฌ๋ง ํฌํจํ ๊ฒ**(One-purpose-only): ์ฌ๊ธฐ์ ๋ค๋ฃฐ ์์๋ค์ ํ๋์ ํ์คํฌ๋ง ํฌํจํ๊ณ ์์ด์ผ ํฉ๋๋ค. ๋ฌผ๋ก ์ด๋ฏธ์ง ์ดํด์ํ(super-resolution)์ ์ด๋ฏธ์ง ๋ณด์ (modification)๊ณผ ๊ฐ์ ์ ์ฌํ ๋ชจ๋ธ๋ง ํ๋ก์ธ์ค๋ฅผ ๊ฐ๋ ํ์คํฌ๋ค์ด ์กด์ฌํ๊ฒ ์ง๋ง, ํ๋์ ์์ ์ ํ๋์ ํ์คํฌ๋ง์ ๋ด๋ ๊ฒ์ด ๋ ์ดํดํ๊ธฐ ์ฉ์ดํ๋ค๊ณ ํ๋จํ๊ธฐ ๋๋ฌธ์
๋๋ค.
์ ํฌ๋ diffusion ๋ชจ๋ธ์ ๋ํ์ ์ธ ํ์คํฌ๋ค์ ๋ค๋ฃจ๋ ๊ณต์ ์์ ๋ฅผ ์ ๊ณตํ๊ณ ์์ต๋๋ค. *๊ณต์* ์์ ๋ ํ์ฌ ์งํํ์ผ๋ก `diffusers` ๊ด๋ฆฌ์๋ค(maintainers)์ ์ํด ๊ด๋ฆฌ๋๊ณ ์์ต๋๋ค. ๋ํ ์ ํฌ๋ ์์ ์ ์ํ ์ ํฌ์ ์ฒ ํ์ ์๊ฒฉํ๊ฒ ๋ฐ๋ฅด๊ณ ์ ๋
ธ๋ ฅํ๊ณ ์์ต๋๋ค. ํน์ ์ฌ๋ฌ๋ถ๊ป์ ์ด๋ฌํ ์์๊ฐ ๋ฐ๋์ ํ์ํ๋ค๊ณ ์๊ฐ๋์ ๋ค๋ฉด, ์ธ์ ๋ ์ง [Feature Request](https://github.com/huggingface/diffusers/issues/new?assignees=&labels=&template=feature_request.md&title=) ํน์ ์ง์ [Pull Request](https://github.com/huggingface/diffusers/compare)๋ฅผ ์ฃผ์๊ธฐ ๋ฐ๋๋๋ค. ์ ํฌ๋ ์ธ์ ๋ ํ์์
๋๋ค!
ํ์ต ์์๋ค์ ๋ค์ํ ํ์คํฌ๋ค์ ๋ํด diffusion ๋ชจ๋ธ์ ์ฌ์ ํ์ต(pretrain)ํ๊ฑฐ๋ ํ์ธํ๋(fine-tuning)ํ๋ ๋ฒ์ ๋ณด์ฌ์ค๋๋ค. ํ์ฌ ๋ค์๊ณผ ๊ฐ์ ์์ ๋ค์ ์ง์ํ๊ณ ์์ต๋๋ค.
- [Unconditional Training](./unconditional_training)
- [Text-to-Image Training](./text2image)
- [Text Inversion](./text_inversion)
- [Dreambooth](./dreambooth)
memory-efficient attention ์ฐ์ฐ์ ์ํํ๊ธฐ ์ํด, ๊ฐ๋ฅํ๋ฉด [xFormers](../optimization/xformers)๋ฅผ ์ค์นํด์ฃผ์๊ธฐ ๋ฐ๋๋๋ค. ์ด๋ฅผ ํตํด ํ์ต ์๋๋ฅผ ๋๋ฆฌ๊ณ ๋ฉ๋ชจ๋ฆฌ์ ๋ํ ๋ถ๋ด์ ์ค์ผ ์ ์์ต๋๋ค.
| Task | ๐ค Accelerate | ๐ค Datasets | Colab
|---|---|:---:|:---:|
| [**Unconditional Image Generation**](./unconditional_training) | โ
| โ
| [](https://colab.research.google.com/github/huggingface/notebooks/blob/main/diffusers/training_example.ipynb)
| [**Text-to-Image fine-tuning**](./text2image) | โ
| โ
|
| [**Textual Inversion**](./text_inversion) | โ
| - | [](https://colab.research.google.com/github/huggingface/notebooks/blob/main/diffusers/sd_textual_inversion_training.ipynb)
| [**Dreambooth**](./dreambooth) | โ
| - | [](https://colab.research.google.com/github/huggingface/notebooks/blob/main/diffusers/sd_dreambooth_training.ipynb)
| [**Training with LoRA**](./lora) | โ
| - | - |
| [**ControlNet**](./controlnet) | โ
| โ
| - |
| [**InstructPix2Pix**](./instructpix2pix) | โ
| โ
| - |
| [**Custom Diffusion**](./custom_diffusion) | โ
| โ
| - |
## ์ปค๋ฎค๋ํฐ
๊ณต์ ์์ ์ธ์๋ **์ปค๋ฎค๋ํฐ ์์ ** ์ญ์ ์ ๊ณตํ๊ณ ์์ต๋๋ค. ํด๋น ์์ ๋ค์ ์ฐ๋ฆฌ์ ์ปค๋ฎค๋ํฐ์ ์ํด ๊ด๋ฆฌ๋ฉ๋๋ค. ์ปค๋ฎค๋ํฐ ์์ฉจ๋ ํ์ต ์์๋ ์ถ๋ก ํ์ดํ๋ผ์ธ์ผ๋ก ๊ตฌ์ฑ๋ ์ ์์ต๋๋ค. ์ด๋ฌํ ์ปค๋ฎค๋ํฐ ์์๋ค์ ๊ฒฝ์ฐ, ์์ ์ ์ํ๋ ์ฒ ํ๋ค์ ์ข ๋ ๊ด๋ํ๊ฒ ์ ์ฉํ๊ณ ์์ต๋๋ค. ๋ํ ์ด๋ฌํ ์ปค๋ฎค๋ํฐ ์์๋ค์ ๊ฒฝ์ฐ, ๋ชจ๋ ์ด์๋ค์ ๋ํ ์ ์ง๋ณด์๋ฅผ ๋ณด์ฅํ ์๋ ์์ต๋๋ค.
์ ์ฉํ๊ธด ํ์ง๋ง, ์์ง์ ๋์ค์ ์ด์ง ๋ชปํ๊ฑฐ๋ ์ ํฌ์ ์ฒ ํ์ ๋ถํฉํ์ง ์๋ ์์ ๋ค์ [community examples](https://github.com/huggingface/diffusers/tree/main/examples/community) ํด๋์ ๋ด๊ธฐ๊ฒ ๋ฉ๋๋ค.
**Note**: ์ปค๋ฎค๋ํฐ ์์ ๋ `diffusers`์ ๊ธฐ์ฌ(contribution)๋ฅผ ํฌ๋งํ๋ ๋ถ๋ค์๊ฒ [์์ฃผ ์ข์ ๊ธฐ์ฌ ์๋จ](https://github.com/huggingface/diffusers/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22)์ด ๋ ์ ์์ต๋๋ค.
## ์ฃผ๋ชฉํ ์ฌํญ๋ค
์ต์ ๋ฒ์ ์ ์์ ์ฝ๋๋ค์ ์ฑ๊ณต์ ์ธ ๊ตฌ๋์ ๋ณด์ฅํ๊ธฐ ์ํด์๋, ๋ฐ๋์ **์์ค์ฝ๋๋ฅผ ํตํด `diffusers`๋ฅผ ์ค์นํด์ผ ํ๋ฉฐ,** ํด๋น ์์ ์ฝ๋๋ค์ด ์๊ตฌํ๋ ๋ํ๋์๋ค ์ญ์ ์ค์นํด์ผ ํฉ๋๋ค. ์ด๋ฅผ ์ํด ์๋ก์ด ๊ฐ์ ํ๊ฒฝ์ ๊ตฌ์ถํ๊ณ ๋ค์์ ๋ช
๋ น์ด๋ฅผ ์คํํด์ผ ํฉ๋๋ค.
```bash
git clone https://github.com/huggingface/diffusers
cd diffusers
pip install .
```
๊ทธ ๋ค์ `cd` ๋ช
๋ น์ด๋ฅผ ํตํด ํด๋น ์์ ๋๋ ํ ๋ฆฌ์ ์ ๊ทผํด์ ๋ค์ ๋ช
๋ น์ด๋ฅผ ์คํํ๋ฉด ๋ฉ๋๋ค.
```bash
pip install -r requirements.txt
``` |