Spaces:
Runtime error
Runtime error
Commit
·
2b4e1f8
1
Parent(s):
876b458
Update app.py
Browse files
app.py
CHANGED
@@ -1,22 +1,11 @@
|
|
1 |
-
import
|
2 |
import torch
|
3 |
-
from PIL import Image
|
4 |
-
from io import BytesIO
|
5 |
|
6 |
-
|
|
|
|
|
7 |
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
url = "https://raw.githubusercontent.com/CompVis/stable-diffusion/main/assets/stable-samples/img2img/sketch-mountains-input.jpg"
|
14 |
-
|
15 |
-
response = requests.get(url)
|
16 |
-
init_image = Image.open(BytesIO(response.content)).convert("RGB")
|
17 |
-
init_image = init_image.resize((768, 512))
|
18 |
-
|
19 |
-
prompt = "A fantasy landscape, trending on artstation"
|
20 |
-
|
21 |
-
images = pipe(prompt=prompt, image=init_image, strength=0.75, guidance_scale=7.5).images
|
22 |
-
images[0].save("fantasy_landscape.png")
|
|
|
1 |
+
from diffusers import StableDiffusionPipeline
|
2 |
import torch
|
|
|
|
|
3 |
|
4 |
+
model_id = "runwayml/stable-diffusion-v1-5"
|
5 |
+
pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
|
6 |
+
pipe = pipe.to("cuda")
|
7 |
|
8 |
+
prompt = "a photo of an astronaut riding a horse on mars"
|
9 |
+
image = pipe(prompt).images[0]
|
10 |
+
|
11 |
+
image.save("astronaut_rides_horse.png")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|