shibing624 commited on
Commit
2ad3bf2
1 Parent(s): eb4d8f9

Create new file

Browse files
Files changed (1) hide show
  1. app.py +42 -0
app.py ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+ @author:XuMing(xuming624@qq.com)
4
+ @description: 中文对联生成
5
+ """
6
+
7
+ import gradio as gr
8
+ from textgen import T5Model
9
+
10
+ # 中文对联生成模型(shibing624/t5-chinese-couplet)
11
+ model = T5Model("t5", "shibing624/t5-chinese-couplet")
12
+
13
+
14
+ def ai_text(sentence):
15
+ out_sentences = model.predict([sentence])
16
+ print("{} \t out: {}".format(sentence, out_sentences[0]))
17
+ return out_sentences[0]
18
+
19
+
20
+ if __name__ == '__main__':
21
+ examples = [
22
+ ['对联:丹枫江冷人初去'],
23
+ ['对联:春回大地,对对黄莺鸣暖树'],
24
+ ['对联:书香醉我凌云梦'],
25
+ ['对联:灵蛇出洞千山秀'],
26
+ ['对联:晚风摇树树还挺'],
27
+ ['对联:幸福体彩彩民喜爱,玩出幸福'],
28
+ ['对联:光华照眼来,谁敢歌吟?诗仙诗圣空千古'],
29
+
30
+ ]
31
+ input = gr.inputs.Textbox(lines=4, placeholder="Enter Sentence")
32
+
33
+ output_text = gr.outputs.Textbox()
34
+ gr.Interface(ai_text,
35
+ inputs=[input],
36
+ outputs=[output_text],
37
+ theme="grass",
38
+ title="Chinese Couplet Generation Model",
39
+ description="Copy or input Chinese text here. Submit and the machine will generate left text.",
40
+ article="Link to <a href='https://github.com/shibing624/textgen' style='color:blue;' target='_blank\'>Github REPO</a>",
41
+ examples=examples
42
+ ).launch()