patrickvonplaten
commited on
Commit
•
b795ca9
1
Parent(s):
8628cf3
up
Browse files- fantasy_landscape.png +3 -0
- run.py +15 -10
fantasy_landscape.png
ADDED
Git LFS Details
|
run.py
CHANGED
@@ -1,16 +1,21 @@
|
|
1 |
-
|
2 |
-
from diffusers import StableDiffusionPipeline
|
3 |
import torch
|
|
|
|
|
4 |
|
5 |
-
|
6 |
-
prompts = ["arcane style", "spiderverse style", "modern disney style", "archer style", "elden ring style"]
|
7 |
|
|
|
|
|
|
|
8 |
|
9 |
-
|
10 |
-
pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
|
11 |
-
pipe = pipe.to("cuda")
|
12 |
|
13 |
-
|
14 |
-
|
|
|
15 |
|
16 |
-
|
|
|
|
|
|
|
|
1 |
+
import requests
|
|
|
2 |
import torch
|
3 |
+
from PIL import Image
|
4 |
+
from io import BytesIO
|
5 |
|
6 |
+
from diffusers import StableUnCLIPImg2ImgPipeline
|
|
|
7 |
|
8 |
+
pipe = StableUnCLIPImg2ImgPipeline.from_pretrained("/home/patrick_huggingface_co/stable-diffusion-2-1-unclip", torch_dtype=torch.float16
|
9 |
+
) # TODO update model path
|
10 |
+
pipe = pipe.to("cuda")
|
11 |
|
12 |
+
url = "https://raw.githubusercontent.com/CompVis/stable-diffusion/main/assets/stable-samples/img2img/sketch-mountains-input.jpg"
|
|
|
|
|
13 |
|
14 |
+
response = requests.get(url)
|
15 |
+
init_image = Image.open(BytesIO(response.content)).convert("RGB")
|
16 |
+
init_image = init_image.resize((768, 512))
|
17 |
|
18 |
+
prompt = "A fantasy landscape, trending on artstation"
|
19 |
+
|
20 |
+
images = pipe(prompt, init_image).images
|
21 |
+
images[0].save("fantasy_landscape.png")
|