Spaces:
Runtime error
Runtime error
Ryouko
commited on
Commit
•
61e0435
1
Parent(s):
0067242
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from diffusers import DiffusionPipeline
|
3 |
+
|
4 |
+
# Load the pre-trained model
|
5 |
+
pipe = DiffusionPipeline.from_pretrained("John6666/mala-anime-mix-nsfw-pony-xl-v3-sdxl")
|
6 |
+
|
7 |
+
# Function to generate image based on the input prompt
|
8 |
+
def generate_image(prompt):
|
9 |
+
image = pipe(prompt).images[0]
|
10 |
+
return image
|
11 |
+
|
12 |
+
# Create the Gradio interface using Blocks
|
13 |
+
with gr.Blocks() as demo:
|
14 |
+
gr.Markdown("# Image Generation with DiffusionPipeline")
|
15 |
+
|
16 |
+
with gr.Row():
|
17 |
+
prompt_input = gr.Textbox(label="Prompt", placeholder="Enter your prompt here")
|
18 |
+
|
19 |
+
with gr.Row():
|
20 |
+
generate_btn = gr.Button("Generate Image")
|
21 |
+
|
22 |
+
with gr.Row():
|
23 |
+
output_image = gr.Image(label="Generated Image")
|
24 |
+
|
25 |
+
# Define the button click event
|
26 |
+
generate_btn.click(fn=generate_image, inputs=prompt_input, outputs=output_image)
|
27 |
+
|
28 |
+
# Launch the Gradio app
|
29 |
+
demo.launch()
|