Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,31 +1,25 @@
|
|
1 |
import gradio as gr
|
2 |
import torch
|
3 |
from diffusers import StableDiffusionPipeline
|
4 |
-
from PIL import Image
|
5 |
|
6 |
-
|
7 |
model_id = "nitrosocke/Ghibli-Diffusion"
|
8 |
-
pipeline = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
|
9 |
-
pipeline.to("cuda") # Ensure GPU acceleration
|
10 |
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
prompt = "Ghibli
|
17 |
-
result =
|
18 |
-
|
19 |
return result
|
20 |
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
outputs=gr.Image(label="Ghibli-style Portrait"),
|
26 |
title="Studio Ghibli Portrait Generator",
|
27 |
-
description="Upload
|
28 |
)
|
29 |
|
30 |
-
|
31 |
-
demo.launch()
|
|
|
1 |
import gradio as gr
|
2 |
import torch
|
3 |
from diffusers import StableDiffusionPipeline
|
|
|
4 |
|
5 |
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
6 |
model_id = "nitrosocke/Ghibli-Diffusion"
|
|
|
|
|
7 |
|
8 |
+
# Load the model
|
9 |
+
pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16 if device == "cuda" else torch.float32)
|
10 |
+
pipe.to(device)
|
11 |
+
|
12 |
+
def generate_ghibli_style(image):
|
13 |
+
prompt = "Studio Ghibli style portrait of a person, highly detailed, beautiful colors"
|
14 |
+
result = pipe(prompt, init_image=image, strength=0.75).images[0]
|
|
|
15 |
return result
|
16 |
|
17 |
+
iface = gr.Interface(
|
18 |
+
fn=generate_ghibli_style,
|
19 |
+
inputs=gr.Image(type="pil"),
|
20 |
+
outputs=gr.Image(),
|
|
|
21 |
title="Studio Ghibli Portrait Generator",
|
22 |
+
description="Upload a photo, and this AI will transform it into a Ghibli-style portrait!"
|
23 |
)
|
24 |
|
25 |
+
iface.launch()
|
|