dongyi commited on
Commit
b35f032
·
1 Parent(s): 7981808

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -4
app.py CHANGED
@@ -1,7 +1,36 @@
1
  import gradio as gr
2
 
3
- def image_classifier(inp):
4
- return {'cat': 0.3, 'dog': 0.7}
5
 
6
- demo = gr.Interface(fn=image_classifier, inputs="image", outputs="label")
7
- demo.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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()