zuozuo commited on
Commit
2e97ecd
·
1 Parent(s): 49ba46b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -12,15 +12,16 @@ tokenizer = BertTokenizer.from_pretrained(".")
12
  model = TFGPT2LMHeadModel.from_pretrained(".")
13
  text_generator = TextGenerationPipeline(model, tokenizer)
14
 
15
- def poem(cls,max_length):
16
  txt = text_generator('[CLS]'+cls, max_length=int(max_length), do_sample=True)
17
- return txt[0]['generated_text'].replace('[CLS]','').replace('[SEP]','').replace(' ','')
18
 
19
  iface = gr.Interface(
20
  fn=poem,
21
  inputs=[
22
  gr.Textbox(lines=1, default="春眠不觉晓,",label="请输入一句诗词:"),
23
- gr.Number(50,label='字数:',default=50),
24
  ],
25
- outputs="text")
 
26
  iface.launch()
 
12
  model = TFGPT2LMHeadModel.from_pretrained(".")
13
  text_generator = TextGenerationPipeline(model, tokenizer)
14
 
15
+ def poem(cls, max_length):
16
  txt = text_generator('[CLS]'+cls, max_length=int(max_length), do_sample=True)
17
+ return txt[0]['generated_text'].replace('[CLS]','').replace('[SEP]','').replace(' ','').replace('。','。\n')
18
 
19
  iface = gr.Interface(
20
  fn=poem,
21
  inputs=[
22
  gr.Textbox(lines=1, default="春眠不觉晓,",label="请输入一句诗词:"),
23
+ gr.Number(50, label='字数:',default=50),
24
  ],
25
+ outputs=gr.Textbox(lines=4))
26
+
27
  iface.launch()