Update README.md
Browse files
README.md
CHANGED
|
@@ -25,21 +25,16 @@ pip install diffusers transformers accelerate
|
|
| 25 |
### Text to image
|
| 26 |
|
| 27 |
```python
|
| 28 |
-
from diffusers import
|
| 29 |
import torch
|
| 30 |
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
t2i_pipe = DiffusionPipeline.from_pretrained("kandinsky-community/kandinsky-2-1", torch_dtype=torch.float16)
|
| 35 |
-
t2i_pipe.to("cuda")
|
| 36 |
|
| 37 |
prompt = "A alien cheeseburger creature eating itself, claymation, cinematic, moody lighting"
|
| 38 |
negative_prompt = "low quality, bad quality"
|
| 39 |
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
image = t2i_pipe(prompt, negative_prompt=negative_prompt, image_embeds=image_embeds, negative_image_embeds=negative_image_embeds, height=768, width=768).images[0]
|
| 43 |
image.save("cheeseburger_monster.png")
|
| 44 |
```
|
| 45 |
|
|
@@ -49,43 +44,27 @@ image.save("cheeseburger_monster.png")
|
|
| 49 |
### Text Guided Image-to-Image Generation
|
| 50 |
|
| 51 |
```python
|
| 52 |
-
from diffusers import
|
| 53 |
import torch
|
| 54 |
-
|
| 55 |
-
from PIL import Image
|
| 56 |
import requests
|
| 57 |
from io import BytesIO
|
|
|
|
|
|
|
| 58 |
|
| 59 |
-
|
| 60 |
-
response = requests.get(url)
|
| 61 |
-
original_image = Image.open(BytesIO(response.content)).convert("RGB")
|
| 62 |
-
original_image = original_image.resize((768, 512))
|
| 63 |
-
|
| 64 |
-
# create prior
|
| 65 |
-
pipe_prior = KandinskyPriorPipeline.from_pretrained(
|
| 66 |
-
"kandinsky-community/kandinsky-2-1-prior", torch_dtype=torch.float16
|
| 67 |
-
)
|
| 68 |
-
pipe_prior.to("cuda")
|
| 69 |
|
| 70 |
-
|
| 71 |
-
pipe = KandinskyImg2ImgPipeline.from_pretrained("kandinsky-community/kandinsky-2-1", torch_dtype=torch.float16)
|
| 72 |
-
pipe.to("cuda")
|
| 73 |
|
| 74 |
prompt = "A fantasy landscape, Cinematic lighting"
|
| 75 |
negative_prompt = "low quality, bad quality"
|
| 76 |
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
image_embeds=image_embeds,
|
| 83 |
-
negative_image_embeds=negative_image_embeds,
|
| 84 |
-
height=768,
|
| 85 |
-
width=768,
|
| 86 |
-
strength=0.3,
|
| 87 |
-
)
|
| 88 |
|
|
|
|
| 89 |
out.images[0].save("fantasy_land.png")
|
| 90 |
```
|
| 91 |
|
|
|
|
| 25 |
### Text to image
|
| 26 |
|
| 27 |
```python
|
| 28 |
+
from diffusers import AutoPipelineForText2Image
|
| 29 |
import torch
|
| 30 |
|
| 31 |
+
pipe = AutoPipelineForText2Image.from_pretrained("kandinsky-community/kandinsky-2-1", torch_dtype=torch.float16)
|
| 32 |
+
pipe.enable_model_cpu_offload()
|
|
|
|
|
|
|
|
|
|
| 33 |
|
| 34 |
prompt = "A alien cheeseburger creature eating itself, claymation, cinematic, moody lighting"
|
| 35 |
negative_prompt = "low quality, bad quality"
|
| 36 |
|
| 37 |
+
image = pipe(prompt=prompt, negative_prompt=negative_prompt, prior_guidance_scale =1.0, height=768, width=768).images[0]
|
|
|
|
|
|
|
| 38 |
image.save("cheeseburger_monster.png")
|
| 39 |
```
|
| 40 |
|
|
|
|
| 44 |
### Text Guided Image-to-Image Generation
|
| 45 |
|
| 46 |
```python
|
| 47 |
+
from diffusers import AutoPipelineForImage2Image
|
| 48 |
import torch
|
|
|
|
|
|
|
| 49 |
import requests
|
| 50 |
from io import BytesIO
|
| 51 |
+
from PIL import Image
|
| 52 |
+
import os
|
| 53 |
|
| 54 |
+
pipe = AutoPipelineForImage2Image.from_pretrained("kandinsky-community/kandinsky-2-1", torch_dtype=torch.float16)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
|
| 56 |
+
pipe.enable_model_cpu_offload()
|
|
|
|
|
|
|
| 57 |
|
| 58 |
prompt = "A fantasy landscape, Cinematic lighting"
|
| 59 |
negative_prompt = "low quality, bad quality"
|
| 60 |
|
| 61 |
+
url = "https://raw.githubusercontent.com/CompVis/stable-diffusion/main/assets/stable-samples/img2img/sketch-mountains-input.jpg"
|
| 62 |
+
|
| 63 |
+
response = requests.get(url)
|
| 64 |
+
original_image = Image.open(BytesIO(response.content)).convert("RGB")
|
| 65 |
+
original_image.thumbnail((768, 768))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
|
| 67 |
+
image = pipe(prompt=prompt, image=original_image, strength=0.3).images[0]
|
| 68 |
out.images[0].save("fantasy_land.png")
|
| 69 |
```
|
| 70 |
|