Daniyal041 commited on
Commit
cde8acb
·
verified ·
1 Parent(s): 4464703

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +34 -0
app.py CHANGED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import replicate
3
+ import os
4
+
5
+ # Stable Diffusion generation function
6
+ def generate_image(prompt):
7
+ output = replicate.run(
8
+ "stability-ai/stable-diffusion-3-5-large:ac732df83cea7fff18b8472768c88ad041fa750ff7682a21affe81863cbe77e4",
9
+ input={"prompt": prompt}
10
+ )
11
+ return output[0]
12
+
13
+ # Gradio interface
14
+ with gr.Blocks(fill_height=True) as demo:
15
+ with gr.Sidebar():
16
+ gr.Markdown("# Stable Diffusion 3.5")
17
+ gr.Markdown("Generate images with SD 3.5 via Replicate API")
18
+ api_key = gr.Textbox(
19
+ label="Enter Replicate API key",
20
+ type="password",
21
+ placeholder="Paste your Replicate API key here (or set as environment variable)"
22
+ )
23
+
24
+ prompt = gr.Textbox(label="Prompt", placeholder="A cute corgi in a astronaut helmet")
25
+ generate_btn = gr.Button("Generate")
26
+ output = gr.Image(label="Generated Image")
27
+
28
+ generate_btn.click(
29
+ fn=generate_image,
30
+ inputs=prompt,
31
+ outputs=output
32
+ )
33
+
34
+ demo.launch()