Update README.md
Browse files
README.md
CHANGED
|
@@ -10,8 +10,49 @@ library_name: diffusers
|
|
| 10 |
|
| 11 |
## How to use the model
|
| 12 |
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
## Tips and Tricks
|
| 16 |
|
| 17 |
-
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
## How to use the model
|
| 12 |
|
| 13 |
+
### Install needed libraries
|
| 14 |
+
|
| 15 |
+
```
|
| 16 |
+
pip install git+https://github.com/huggingface/diffusers.git transformers==4.42.4 accelerate xformers peft sentencepiece protobuf -q
|
| 17 |
+
```
|
| 18 |
+
|
| 19 |
+
### Execution code
|
| 20 |
+
|
| 21 |
+
```python
|
| 22 |
+
import numpy as np
|
| 23 |
+
import random
|
| 24 |
+
import torch
|
| 25 |
+
from diffusers import DiffusionPipeline, FlowMatchEulerDiscreteScheduler, AutoencoderTiny, AutoencoderKL
|
| 26 |
+
from transformers import CLIPTextModel, CLIPTokenizer,T5EncoderModel, T5TokenizerFast
|
| 27 |
+
|
| 28 |
+
dtype = torch.bfloat16
|
| 29 |
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 30 |
+
|
| 31 |
+
taef1 = AutoencoderTiny.from_pretrained("madebyollin/taef1", torch_dtype=dtype).to(device)
|
| 32 |
+
pipe = DiffusionPipeline.from_pretrained("mann-e/mann-e_flux", torch_dtype=dtype, vae=taef1).to(device)
|
| 33 |
+
torch.cuda.empty_cache()
|
| 34 |
+
|
| 35 |
+
MAX_SEED = np.iinfo(np.int32).max
|
| 36 |
+
MAX_IMAGE_SIZE = 2048
|
| 37 |
+
|
| 38 |
+
seed = random.randint(0, MAX_SEED)
|
| 39 |
+
generator = torch.Generator().manual_seed(seed)
|
| 40 |
+
|
| 41 |
+
prompt = "an astronaut riding a horse"
|
| 42 |
+
|
| 43 |
+
pipe(
|
| 44 |
+
prompt=f"{prompt}",
|
| 45 |
+
guidance_scale=3.5,
|
| 46 |
+
num_inference_steps=10,
|
| 47 |
+
width=720,
|
| 48 |
+
height=1280,
|
| 49 |
+
generator=generator,
|
| 50 |
+
output_type="pil"
|
| 51 |
+
).images[0].save("output.png")
|
| 52 |
+
```
|
| 53 |
|
| 54 |
## Tips and Tricks
|
| 55 |
|
| 56 |
+
1. Adding `mj-v6.1-style` to the prompts specially the cinematic and photo realistic prompts can make the result quality high as hell! Give it a try.
|
| 57 |
+
2. The best `guidance_scale` is somewhere between 3.5 and 5.0
|
| 58 |
+
3. Inference steps between 8 and 16 are working very well.
|