README
Browse files
README.md
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Mini Stable Diffusion (miniSD)
|
| 2 |
+
|
| 3 |
+
MiniSD is a latent text-to-image diffusion model that has been conditionned on 256x256 images through finetuning.
|
| 4 |
+
|
| 5 |
+
## Examples
|
| 6 |
+
|
| 7 |
+
WIP
|
| 8 |
+
|
| 9 |
+
## Usage
|
| 10 |
+
|
| 11 |
+
```
|
| 12 |
+
!pip install diffusers==0.3.0
|
| 13 |
+
!pip install transformers scipy ftfy
|
| 14 |
+
```
|
| 15 |
+
|
| 16 |
+
```
|
| 17 |
+
import torch
|
| 18 |
+
from diffusers import StableDiffusionPipeline
|
| 19 |
+
from torch import autocast
|
| 20 |
+
|
| 21 |
+
# TODO: change model_id to "lambdalabs/miniSD"
|
| 22 |
+
pipe = StableDiffusionPipeline.from_pretrained("eolecvk/model-test", torch_dtype=torch.float16)
|
| 23 |
+
pipe = pipe.to("cuda")
|
| 24 |
+
|
| 25 |
+
prompt = "Yoda"
|
| 26 |
+
scale = 10
|
| 27 |
+
n_samples = 4
|
| 28 |
+
|
| 29 |
+
# Sometimes the nsfw checker is confused, you can disable it at your own risk here
|
| 30 |
+
disable_safety = False
|
| 31 |
+
|
| 32 |
+
if disable_safety:
|
| 33 |
+
def null_safety(images, **kwargs):
|
| 34 |
+
return images, False
|
| 35 |
+
pipe.safety_checker = null_safety
|
| 36 |
+
|
| 37 |
+
with autocast("cuda"):
|
| 38 |
+
images = pipe(n_samples*[prompt], guidance_scale=scale).images
|
| 39 |
+
|
| 40 |
+
for idx, im in enumerate(images):
|
| 41 |
+
im.save(f"{idx:06}.png")
|
| 42 |
+
```
|
| 43 |
+
|