Update app.py
Browse files
app.py
CHANGED
@@ -1,22 +1,18 @@
|
|
1 |
-
# import gradio as gr
|
2 |
-
|
3 |
-
# gr.load("models/prithivMLmods/SD3.5-Large-Photorealistic-LoRA").launch()
|
4 |
-
|
5 |
import gradio as gr
|
6 |
import random
|
7 |
|
8 |
-
#
|
9 |
model = gr.load("models/prithivMLmods/SD3.5-Large-Photorealistic-LoRA")
|
10 |
|
11 |
-
#
|
12 |
def generate_image(prompt, seed=None):
|
13 |
if seed is None:
|
14 |
-
seed = random.randint(0, 1e6) #
|
15 |
-
#
|
16 |
-
result = model(prompt
|
17 |
return result
|
18 |
|
19 |
-
# 使用 Gradio Blocks
|
20 |
with gr.Blocks() as demo:
|
21 |
gr.Markdown("## 输入描述和种子以生成图像")
|
22 |
prompt = gr.Textbox(label="描述")
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
import random
|
3 |
|
4 |
+
# 加载 Hugging Face 模型,返回 Gradio Blocks 对象
|
5 |
model = gr.load("models/prithivMLmods/SD3.5-Large-Photorealistic-LoRA")
|
6 |
|
7 |
+
# 定义生成函数,使用 predict() 方法并传入 seed 参数
|
8 |
def generate_image(prompt, seed=None):
|
9 |
if seed is None:
|
10 |
+
seed = random.randint(0, 1e6) # 如果用户未指定种子,则生成随机数
|
11 |
+
# 将 prompt 和 seed 作为列表传入 predict 方法
|
12 |
+
result = model.predict(prompt, seed)
|
13 |
return result
|
14 |
|
15 |
+
# 使用 Gradio Blocks 创建界面
|
16 |
with gr.Blocks() as demo:
|
17 |
gr.Markdown("## 输入描述和种子以生成图像")
|
18 |
prompt = gr.Textbox(label="描述")
|