Update app.py
Browse files
app.py
CHANGED
@@ -1,30 +1,31 @@
|
|
1 |
import gradio as gr
|
2 |
|
3 |
# 加载模型并配置
|
4 |
-
model = gr.load("models/prithivMLmods/SD3.5-Large-Photorealistic-LoRA")
|
|
|
5 |
|
6 |
-
#
|
7 |
-
|
8 |
-
#
|
9 |
-
|
10 |
-
|
11 |
|
12 |
-
#
|
13 |
-
|
14 |
-
|
15 |
|
16 |
-
#
|
17 |
-
|
18 |
|
19 |
-
#
|
20 |
-
|
21 |
|
22 |
-
#
|
23 |
-
|
24 |
|
25 |
-
#
|
26 |
-
|
27 |
-
|
28 |
|
29 |
-
#
|
30 |
-
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
# 加载模型并配置
|
4 |
+
model = gr.load("models/prithivMLmods/SD3.5-Large-Photorealistic-LoRA")
|
5 |
+
# .launch()
|
6 |
|
7 |
+
# 定义图像生成函数,添加seed参数
|
8 |
+
def generate_image(prompt, seed):
|
9 |
+
# 调用模型的predict方法并传递种子
|
10 |
+
result = model.predict(prompt=prompt, seed=seed)
|
11 |
+
return result
|
12 |
|
13 |
+
# 创建Gradio界面
|
14 |
+
with gr.Blocks() as demo:
|
15 |
+
gr.Markdown("## Stable Diffusion Image Generation with Seed Control")
|
16 |
|
17 |
+
# 输入框:提示文本
|
18 |
+
prompt_input = gr.Textbox(label="Prompt", value="Man in the style of dark beige and brown, uhd image, youthful protagonists, nonrepresentational photography")
|
19 |
|
20 |
+
# 滑块:种子
|
21 |
+
seed_input = gr.Slider(minimum=0, maximum=100000, step=1, label="Seed", value=42)
|
22 |
|
23 |
+
# 输出图像
|
24 |
+
output_image = gr.Image(type="pil", label="Generated Image")
|
25 |
|
26 |
+
# 按钮触发事件
|
27 |
+
generate_btn = gr.Button("Generate Image")
|
28 |
+
generate_btn.click(generate_image, inputs=[prompt_input, seed_input], outputs=output_image)
|
29 |
|
30 |
+
# 启动Gradio应用
|
31 |
+
demo.launch()
|