Spaces:
Runtime error
Runtime error
Commit
·
7979503
1
Parent(s):
a7951ec
Update app.py
Browse files
app.py
CHANGED
@@ -1,15 +1,27 @@
|
|
1 |
import gradio as gr
|
2 |
from diffusers import DiffusionPipeline
|
3 |
|
4 |
-
|
|
|
|
|
5 |
|
|
|
6 |
def generate_image(prompt):
|
7 |
-
|
8 |
-
|
9 |
-
return image
|
10 |
-
else:
|
11 |
-
return None
|
12 |
|
13 |
-
|
|
|
|
|
14 |
|
15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
from diffusers import DiffusionPipeline
|
3 |
|
4 |
+
# Initialize the DiffusionPipeline with the specified model
|
5 |
+
pipeline = DiffusionPipeline.from_pretrained("stablediffusionapi/juggernaut-xl-v5")
|
6 |
+
pipeline.load_lora_weights("openskyml/dalle-3-xl")
|
7 |
|
8 |
+
# Function to generate image based on the prompt
|
9 |
def generate_image(prompt):
|
10 |
+
image = pipeline(prompt).images[0]
|
11 |
+
return image
|
|
|
|
|
|
|
12 |
|
13 |
+
# Define the Gradio interface layout
|
14 |
+
prompt_input = gr.textbox(label="", placeholder="Enter your prompt here...", lines=1, unresizeable=False)
|
15 |
+
image_output = gr.Image(label="Generated Image")
|
16 |
|
17 |
+
# Create the Gradio interface with a more organized layout
|
18 |
+
gr.Interface(
|
19 |
+
fn=generate_image,
|
20 |
+
inputs=gr.Textbox(lines=5, label="Enter Prompt", placeholder="Enter your prompt here..."),
|
21 |
+
outputs="image",
|
22 |
+
title="OpenJourney Image Generation",
|
23 |
+
theme="compact", # Use a more compact theme for the interface
|
24 |
+
layout="vertical", # Arrange the interface components vertically
|
25 |
+
inputs=[prompt_input],
|
26 |
+
outputs=image_output
|
27 |
+
).launch()
|