dongyi commited on
Commit
9cb47b2
1 Parent(s): b35f032

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +36 -17
app.py CHANGED
@@ -1,36 +1,55 @@
1
  import gradio as gr
2
 
3
- def generate_text(title, context):
4
- return f"Title:{title}\nContext:{context}\n..."
 
5
 
6
- def generate_mutimodal(title, context, img):
 
 
 
 
 
 
 
 
 
7
  return f"Title:{title}\nContext:{context}\n...{img}"
8
 
9
  with gr.Blocks() as demo:
10
  # 顶部文字
11
- gr.Markdown("# 多模态可控XX生成")
12
 
13
  # 多个tab
14
  with gr.Tabs():
15
 
16
- with gr.TabItem("新闻输入"):
17
- title = gr.Textbox(label="标题", lines=1, placeholder="请输入标题")
18
- context = gr.Textbox(label="正文", lines=2, placeholder="请输入正文")
19
- text_button = gr.Button("生成")
20
 
21
- text_output = gr.Textbox(label="生成内容", lines=5, placeholder="生成列表")
 
 
 
 
 
 
 
22
 
 
23
 
24
- with gr.TabItem("图文输入"):
25
- title = gr.Textbox(label="标题", lines=1, placeholder="请输入标题")
26
- context = gr.Textbox(label="正文", lines=2, placeholder="请输入正文")
27
- img = gr.Image(shape=(200, 200), label="请上传图片")
28
- img_button = gr.Button("生成")
 
29
 
30
- img_output = gr.Textbox(label="生成内容", lines=5, placeholder="生成列表")
31
 
32
 
33
- text_button.click(fn=generate_text, inputs=[title,context], outputs=text_output)
34
- img_button.click(fn=generate_mutimodal, inputs=[title,context,img], outputs=img_output)
 
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()