patrickvonplaten sayakpaul HF staff commited on
Commit
3dd0970
1 Parent(s): bc45132

Simplify image loading (#1)

Browse files

- Update README.md (92980448b67adf966e50aaf590800d97075b53b5)
- import torch (889434a47227d6659d17b96ff968ccf9bc1edf12)


Co-authored-by: Sayak Paul <[email protected]>

Files changed (1) hide show
  1. README.md +3 -7
README.md CHANGED
@@ -42,20 +42,16 @@ pip install git+https://github.com/diffusers.git transformers accelerate scipy s
42
  Running the pipeline (if you don't swap the scheduler it will run with the default DDIM, in this example we are swapping it to DPMSolverMultistepScheduler):
43
 
44
  ```python
45
- import requests
46
- import torch
47
- from PIL import Image
48
- from io import BytesIO
49
-
50
  from diffusers import DiffusionPipeline
 
 
51
 
52
  pipe = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-2-1-unclip-small", torch_dtype=torch.float16)
53
  pipe.to("cuda")
54
 
55
  # get image
56
  url = "https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/stable_unclip/tarsila_do_amaral.png"
57
- response = requests.get(url)
58
- image = Image.open(BytesIO(response.content)).convert("RGB")
59
 
60
  # run image variation
61
  image = pipe(image).images[0]
 
42
  Running the pipeline (if you don't swap the scheduler it will run with the default DDIM, in this example we are swapping it to DPMSolverMultistepScheduler):
43
 
44
  ```python
 
 
 
 
 
45
  from diffusers import DiffusionPipeline
46
+ from diffusers.utils import load_image
47
+ import torch
48
 
49
  pipe = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-2-1-unclip-small", torch_dtype=torch.float16)
50
  pipe.to("cuda")
51
 
52
  # get image
53
  url = "https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/stable_unclip/tarsila_do_amaral.png"
54
+ image = load_image(url)
 
55
 
56
  # run image variation
57
  image = pipe(image).images[0]