Update text-to-image-image-to-text
Browse files- text-to-image-image-to-text +52 -1
text-to-image-image-to-text
CHANGED
@@ -10,4 +10,55 @@ pipeline.enable_model_cpu_offload()
|
|
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|
14 |
+
|
15 |
+
pipeline = AutoPipelineForImage2Image.from_pretrained(
|
16 |
+
"kandinsky-community/kandinsky-2-2-decoder", torch_dtype=torch.float16, use_safetensors=True
|
17 |
+
)
|
18 |
+
pipeline.enable_model_cpu_offload()
|
19 |
+
# remove following line if xFormers is not installed or you have PyTorch 2.0 or higher installed
|
20 |
+
pipeline.enable_xformers_memory_efficient_attention()
|
21 |
+
|
22 |
+
image2image = pipeline("Astronaut in a jungle, cold color palette, muted colors, detailed, 8k", image=text2image).images[0]
|
23 |
+
make_image_grid([text2image, image2image], rows=1, cols=2)
|
24 |
+
|
25 |
+
import torch
|
26 |
+
from diffusers import AutoPipelineForImage2Image
|
27 |
+
from diffusers.utils import make_image_grid, load_image
|
28 |
+
|
29 |
+
pipeline = AutoPipelineForImage2Image.from_pretrained(
|
30 |
+
"runwayml/stable-diffusion-v1-5", torch_dtype=torch.float16, variant="fp16", use_safetensors=True
|
31 |
+
)
|
32 |
+
pipeline.enable_model_cpu_offload()
|
33 |
+
# remove following line if xFormers is not installed or you have PyTorch 2.0 or higher installed
|
34 |
+
pipeline.enable_xformers_memory_efficient_attention()
|
35 |
+
|
36 |
+
# prepare image
|
37 |
+
url = "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/img2img-init.png"
|
38 |
+
init_image = load_image(url)
|
39 |
+
|
40 |
+
prompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k"
|
41 |
+
|
42 |
+
# pass prompt and image to pipeline
|
43 |
+
image = pipeline(prompt, image=init_image, output_type="latent").images[0]
|
44 |
+
|
45 |
+
pipeline = AutoPipelineForImage2Image.from_pretrained(
|
46 |
+
"ogkalu/Comic-Diffusion", torch_dtype=torch.float16
|
47 |
+
)
|
48 |
+
pipeline.enable_model_cpu_offload()
|
49 |
+
# remove following line if xFormers is not installed or you have PyTorch 2.0 or higher installed
|
50 |
+
pipeline.enable_xformers_memory_efficient_attention()
|
51 |
+
|
52 |
+
# need to include the token "charliebo artstyle" in the prompt to use this checkpoint
|
53 |
+
image = pipeline("Astronaut in a jungle, charliebo artstyle", image=image, output_type="latent").images[0]
|
54 |
+
|
55 |
+
pipeline = AutoPipelineForImage2Image.from_pretrained(
|
56 |
+
"kohbanye/pixel-art-style", torch_dtype=torch.float16
|
57 |
+
)
|
58 |
+
pipeline.enable_model_cpu_offload()
|
59 |
+
# remove following line if xFormers is not installed or you have PyTorch 2.0 or higher installed
|
60 |
+
pipeline.enable_xformers_memory_efficient_attention()
|
61 |
+
|
62 |
+
# need to include the token "pixelartstyle" in the prompt to use this checkpoint
|
63 |
+
image = pipeline("Astronaut in a jungle, pixelartstyle", image=image).images[0]
|
64 |
+
make_image_grid([init_image, image], rows=1, cols=2)
|