YiYiXu commited on
Commit
44eb212
1 Parent(s): d44c9d6

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +8 -29
README.md CHANGED
@@ -25,21 +25,16 @@ pip install diffusers transformers accelerate
25
  ### Text to image
26
 
27
  ```python
28
- from diffusers import DiffusionPipeline
29
  import torch
30
 
31
- pipe_prior = DiffusionPipeline.from_pretrained("kandinsky-community/kandinsky-2-2-prior", torch_dtype=torch.float16)
32
- pipe_prior.to("cuda")
33
-
34
- t2i_pipe = DiffusionPipeline.from_pretrained("kandinsky-community/kandinsky-2-2-decoder", torch_dtype=torch.float16)
35
- t2i_pipe.to("cuda")
36
 
37
  prompt = "portrait of a young women, blue eyes, cinematic"
38
  negative_prompt = "low quality, bad quality"
39
 
40
- image_embeds, negative_image_embeds = pipe_prior(prompt, negative_prompt, guidance_scale=1.0).to_tuple()
41
-
42
- image = t2i_pipe(image_embeds=image_embeds, negative_image_embeds=negative_image_embeds, height=768, width=768).images[0]
43
  image.save("portrait.png")
44
  ```
45
 
@@ -61,32 +56,16 @@ original_image = original_image.resize((768, 512))
61
  ![img](https://raw.githubusercontent.com/CompVis/stable-diffusion/main/assets/stable-samples/img2img/sketch-mountains-input.jpg)
62
 
63
  ```python
64
- from diffusers import KandinskyV22Img2ImgPipeline, KandinskyV22PriorPipeline
65
  import torch
66
 
67
- # create prior
68
- pipe_prior = KandinskyV22PriorPipeline.from_pretrained(
69
- "kandinsky-community/kandinsky-2-2-prior", torch_dtype=torch.float16
70
- )
71
- pipe_prior.to("cuda")
72
-
73
- # create img2img pipeline
74
- pipe = KandinskyV22Img2ImgPipeline.from_pretrained("kandinsky-community/kandinsky-2-2-decoder", torch_dtype=torch.float16)
75
- pipe.to("cuda")
76
 
77
  prompt = "A fantasy landscape, Cinematic lighting"
78
  negative_prompt = "low quality, bad quality"
79
 
80
- image_embeds, negative_image_embeds = pipe_prior(prompt, negative_prompt).to_tuple()
81
-
82
- out = pipe(
83
- image=original_image,
84
- image_embeds=image_embeds,
85
- negative_image_embeds=negative_image_embeds,
86
- height=768,
87
- width=768,
88
- strength=0.3,
89
- )
90
 
91
  out.images[0].save("fantasy_land.png")
92
  ```
 
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-2-decoder", torch_dtype=torch.float16)
32
+ pipe = pipe.to("cuda")
 
 
 
33
 
34
  prompt = "portrait of a young women, blue eyes, cinematic"
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("portrait.png")
39
  ```
40
 
 
56
  ![img](https://raw.githubusercontent.com/CompVis/stable-diffusion/main/assets/stable-samples/img2img/sketch-mountains-input.jpg)
57
 
58
  ```python
59
+ from diffusers import AutoPipelineForImage2Image
60
  import torch
61
 
62
+ pipe = AutoPipelineForImage2Image.from_pretrained("kandinsky-community/kandinsky-2-2-decoder", torch_dtype=torch.float16)
63
+ pipe.enable_model_cpu_offload()
 
 
 
 
 
 
 
64
 
65
  prompt = "A fantasy landscape, Cinematic lighting"
66
  negative_prompt = "low quality, bad quality"
67
 
68
+ image = pipe(prompt=prompt, image=original_image, strength=0.3, height=768, width=768).images[0]
 
 
 
 
 
 
 
 
 
69
 
70
  out.images[0].save("fantasy_land.png")
71
  ```