gengs commited on
Commit
83c0970
·
verified ·
1 Parent(s): e960b89

Update app.py

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