Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,36 +1,55 @@
|
|
1 |
import gradio as gr
|
2 |
|
3 |
-
def
|
4 |
-
|
|
|
5 |
|
6 |
-
def
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
return f"Title:{title}\nContext:{context}\n...{img}"
|
8 |
|
9 |
with gr.Blocks() as demo:
|
10 |
# 顶部文字
|
11 |
-
gr.Markdown("#
|
12 |
|
13 |
# 多个tab
|
14 |
with gr.Tabs():
|
15 |
|
16 |
-
with gr.TabItem("
|
17 |
-
|
18 |
-
|
19 |
-
text_button = gr.Button("生成")
|
20 |
|
21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
|
|
|
23 |
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
|
|
29 |
|
30 |
-
|
31 |
|
32 |
|
33 |
-
|
34 |
-
|
|
|
35 |
|
36 |
demo.launch()
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
+
def generate_multi_model(input_img):
|
4 |
+
output_img = input_img
|
5 |
+
return output_img
|
6 |
|
7 |
+
def train_one_shot(title, context, img):
|
8 |
+
return f"Title:{title}\nContext:{context}\n...{img}"
|
9 |
+
|
10 |
+
def generate_one_shot(title, context, img):
|
11 |
+
return f"Title:{title}\nContext:{context}\n...{img}"
|
12 |
+
|
13 |
+
def train_zero_shot(title, context, img):
|
14 |
+
return f"Title:{title}\nContext:{context}\n...{img}"
|
15 |
+
|
16 |
+
def generate_zero_shot(title, context, img):
|
17 |
return f"Title:{title}\nContext:{context}\n...{img}"
|
18 |
|
19 |
with gr.Blocks() as demo:
|
20 |
# 顶部文字
|
21 |
+
gr.Markdown("# MMFS")
|
22 |
|
23 |
# 多个tab
|
24 |
with gr.Tabs():
|
25 |
|
26 |
+
with gr.TabItem("multi-model"):
|
27 |
+
multi_input_img = gr.Image(shape=(200, 200), label="请上传人像图片")
|
28 |
+
multi_model_button = gr.Button("随机风格化")
|
|
|
29 |
|
30 |
+
multi_output_img = gr.Image(shape=(200, 200), label="人像风格化图")
|
31 |
+
|
32 |
+
|
33 |
+
with gr.TabItem("one-shot"):
|
34 |
+
one_shot_src_img = gr.Image(shape=(200, 200), label="请上传内容图片")
|
35 |
+
one_shot_ref_img = gr.Image(shape=(200, 200), label="请上传风格图片")
|
36 |
+
one_shot_train_button = gr.Button("训练模型")
|
37 |
+
one_shot_test_button = gr.Button("风格化")
|
38 |
|
39 |
+
one_shot_output_img = gr.Image(shape=(200, 200), label="one-shot风格化图")
|
40 |
|
41 |
+
|
42 |
+
with gr.TabItem("zero-shot"):
|
43 |
+
zero_shot_src_img = gr.Image(shape=(200, 200), label="请上传内容图片")
|
44 |
+
zero_shot_ref_prompt = gr.Textbox(label="prompt", lines=1, placeholder="请输入参考风格描述(英文)")
|
45 |
+
zero_shot_train_button = gr.Button("训练模型")
|
46 |
+
zero_shot_test_button = gr.Button("风格化")
|
47 |
|
48 |
+
zero_shot_output_img = gr.Image(shape=(200, 200), label="zero-shot风格化图")
|
49 |
|
50 |
|
51 |
+
multi_model_button.click(fn=generate_multi_model, inputs=multi_input_img, outputs=multi_output_img)
|
52 |
+
one_shot_test_button.click(fn=generate_one_shot, inputs=[title,context,img], outputs=img_output)
|
53 |
+
zero_shot_test_button.click(fn=generate_zero_shot, inputs=[title,context,img], outputs=img_output)
|
54 |
|
55 |
demo.launch()
|