Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,26 +1,26 @@
|
|
1 |
import os
|
2 |
import gradio as gr
|
3 |
-
import
|
4 |
from PIL import Image
|
5 |
import io
|
6 |
|
7 |
-
|
8 |
api_key = os.getenv("API_KEY")
|
9 |
|
10 |
-
def
|
11 |
-
|
12 |
-
|
13 |
-
return response.content
|
14 |
|
15 |
-
|
16 |
-
|
17 |
-
"inputs": prompt,
|
18 |
-
}
|
19 |
-
image_bytes = query(input_prompt)
|
20 |
-
image = Image.open(io.BytesIO(image_bytes))
|
21 |
-
return image
|
22 |
|
23 |
title = "Stable Fiddusion XL"
|
24 |
-
description = "This app generates an image based on the provided prompt using the Stable Diffusion XL model."
|
25 |
|
26 |
-
gr.Interface(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import os
|
2 |
import gradio as gr
|
3 |
+
from diffusers import DiffusionPipeline
|
4 |
from PIL import Image
|
5 |
import io
|
6 |
|
7 |
+
pipeline = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0")
|
8 |
api_key = os.getenv("API_KEY")
|
9 |
|
10 |
+
def generate_image_with_stylization(prompt, style):
|
11 |
+
input_prompt = prompt
|
12 |
+
generated_image = pipeline.diffuse_text(input_prompt, stylize=True, style_prompt=style)
|
|
|
13 |
|
14 |
+
img = Image.fromarray(generated_image)
|
15 |
+
return img
|
|
|
|
|
|
|
|
|
|
|
16 |
|
17 |
title = "Stable Fiddusion XL"
|
18 |
+
description = "This app generates an image based on the provided prompt using the Stable Diffusion XL model, applying stylization."
|
19 |
|
20 |
+
gr.Interface(
|
21 |
+
fn=generate_image_with_stylization,
|
22 |
+
inputs=["text", gr.inputs.Textbox(label="Style")],
|
23 |
+
outputs="image",
|
24 |
+
title=title,
|
25 |
+
description=description
|
26 |
+
).launch()
|