patrickvonplaten commited on
Commit
dd706b8
1 Parent(s): e9f687c

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +14 -12
README.md CHANGED
@@ -66,30 +66,32 @@ pip install git+https://github.com/huggingface/transformers
66
  To use Versatile Diffusion for all tasks, it is recommend to use the [`VersatileDiffusionPipeline`](https://huggingface.co/docs/diffusers/main/en/api/pipelines/versatile_diffusion#diffusers.VersatileDiffusionPipeline)
67
 
68
  ```py
 
69
  from diffusers import VersatileDiffusionPipeline
70
  import torch
71
  import requests
72
  from io import BytesIO
73
  from PIL import Image
74
 
75
- # let's download an initial image
76
- url = "https://huggingface.co/datasets/diffusers/images/resolve/main/benz.jpg"
77
 
 
 
 
 
 
78
  response = requests.get(url)
79
  image = Image.open(BytesIO(response.content)).convert("RGB")
80
 
81
- pipe = VersatileDiffusionPipeline.from_pretrained(
82
- "shi-labs/versatile-diffusion", torch_dtype=torch.float16
83
- )
84
- pipe = pipe.to("cuda")
85
 
86
- generator = torch.Generator(device="cuda").manual_seed(0)
87
- image = pipe.image_variation(image, generator=generator).images[0]
88
- image.save("./car_variation.png")
89
 
90
- #similarly with
91
- # pipe.text_to_image(...)
92
- # pipe.dual_guided(...)
93
  ```
94
 
95
  ### Task Specific
 
66
  To use Versatile Diffusion for all tasks, it is recommend to use the [`VersatileDiffusionPipeline`](https://huggingface.co/docs/diffusers/main/en/api/pipelines/versatile_diffusion#diffusers.VersatileDiffusionPipeline)
67
 
68
  ```py
69
+ #! pip install git+https://github.com/huggingface/transformers diffusers torch
70
  from diffusers import VersatileDiffusionPipeline
71
  import torch
72
  import requests
73
  from io import BytesIO
74
  from PIL import Image
75
 
76
+ pipe = VersatileDiffusionPipeline.from_pretrained("shi-labs/versatile-diffusion", torch_dtype=torch.float16)
77
+ pipe = pipe.to("cuda")
78
 
79
+ # prompt
80
+ prompt = "a red car"
81
+
82
+ # initial image
83
+ url = "https://huggingface.co/datasets/diffusers/images/resolve/main/benz.jpg"
84
  response = requests.get(url)
85
  image = Image.open(BytesIO(response.content)).convert("RGB")
86
 
87
+ # text to image
88
+ image = pipe.text_to_image(prompt).images[0]
 
 
89
 
90
+ # image variation
91
+ image = pipe.image_variation(image).images[0]
 
92
 
93
+ # image variation
94
+ image = pipe.dual_guided(prompt, image).images[0]
 
95
  ```
96
 
97
  ### Task Specific