Spaces:
Runtime error
Runtime error
cuneytkaya
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -5,8 +5,14 @@ from PIL import Image
|
|
5 |
|
6 |
|
7 |
model_id = "CompVis/stable-diffusion-v1-4"
|
8 |
-
|
9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
|
11 |
def stylize_image(input_image, prompt):
|
12 |
input_image = input_image.convert("RGB")
|
@@ -18,14 +24,14 @@ def stylize_image(input_image, prompt):
|
|
18 |
iface = gr.Interface(
|
19 |
fn=stylize_image,
|
20 |
inputs=[
|
21 |
-
gr.Image(type="pil", label="Upload your image"),
|
22 |
-
gr.Textbox(placeholder="Enter the art style... (e.g., Van Gogh style)", label="Art Style", lines=1)
|
23 |
],
|
24 |
-
outputs=gr.Image(label="Stylized Image"),
|
25 |
-
title="Art and Style Transfer Demo",
|
26 |
-
description="This demo uses the Stable Diffusion model to transform an image into a specified art style. Upload an image and enter a style prompt to get started.",
|
27 |
examples=[
|
28 |
-
["ben-grayland-gD-TjgDW0so-unsplash.jpg", "Van Gogh style"],
|
29 |
]
|
30 |
)
|
31 |
|
|
|
5 |
|
6 |
|
7 |
model_id = "CompVis/stable-diffusion-v1-4"
|
8 |
+
|
9 |
+
|
10 |
+
if torch.cuda.is_available():
|
11 |
+
pipe = StableDiffusionImg2ImgPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
|
12 |
+
pipe = pipe.to("cuda")
|
13 |
+
else:
|
14 |
+
pipe = StableDiffusionImg2ImgPipeline.from_pretrained(model_id)
|
15 |
+
pipe = pipe.to("cpu")
|
16 |
|
17 |
def stylize_image(input_image, prompt):
|
18 |
input_image = input_image.convert("RGB")
|
|
|
24 |
iface = gr.Interface(
|
25 |
fn=stylize_image,
|
26 |
inputs=[
|
27 |
+
gr.Image(type="pil", label="Upload your image"),
|
28 |
+
gr.Textbox(placeholder="Enter the art style... (e.g., Van Gogh style)", label="Art Style", lines=1)
|
29 |
],
|
30 |
+
outputs=gr.Image(label="Stylized Image"),
|
31 |
+
title="Art and Style Transfer Demo",
|
32 |
+
description="This demo uses the Stable Diffusion model to transform an image into a specified art style. Upload an image and enter a style prompt to get started.",
|
33 |
examples=[
|
34 |
+
["ben-grayland-gD-TjgDW0so-unsplash.jpg", "Van Gogh style"],
|
35 |
]
|
36 |
)
|
37 |
|