Create text-to-image-image-to-text
Browse files- text-to-image-image-to-text +13 -0
text-to-image-image-to-text
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from diffusers import AutoPipelineForText2Image, AutoPipelineForImage2Image
|
2 |
+
import torch
|
3 |
+
from diffusers.utils import make_image_grid
|
4 |
+
|
5 |
+
pipeline = AutoPipelineForText2Image.from_pretrained(
|
6 |
+
"runwayml/stable-diffusion-v1-5", torch_dtype=torch.float16, variant="fp16", use_safetensors=True
|
7 |
+
)
|
8 |
+
pipeline.enable_model_cpu_offload()
|
9 |
+
# remove following line if xFormers is not installed or you have PyTorch 2.0 or higher installed
|
10 |
+
pipeline.enable_xformers_memory_efficient_attention()
|
11 |
+
|
12 |
+
text2image = pipeline("Astronaut in a jungle, cold color palette, muted colors, detailed, 8k").images[0]
|
13 |
+
text2image
|