Lifan-Z commited on
Commit
1808e26
1 Parent(s): 272cc9f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -2
app.py CHANGED
@@ -6,7 +6,7 @@ gpt2 = pipeline('text-generation', model = "Lifan-Z/Chinese-Classic-Poem-Generat
6
 
7
  def poems(st):
8
  poems=""
9
- sequences = gpt2('<|endoftext|>'+st, max_length=50, do_sample=True, top_k=20, top_p=0.9, repetition_penalty=1.2, num_return_sequences=20, eos_token_id=0)
10
  i=0
11
  for seq in sequences:
12
  if (len(seq.get('generated_text')) == 108):
@@ -15,7 +15,7 @@ def poems(st):
15
  if(i==6):
16
  return(poems)
17
 
18
- textbox = gr.Textbox(label="输入0~5个汉字作为诗的开头,以英文空格分隔。(Enter 0~5 Chinese characters to be the beginning of the poem, separated by a space. )", placeholder="白 日 依 山 尽", lines=17)
19
 
20
  iface = gr.Interface(fn=poems, inputs=textbox, outputs="text")
21
  iface.launch()
 
6
 
7
  def poems(st):
8
  poems=""
9
+ sequences = gpt2('<|endoftext|>'+st, max_length=50, do_sample=True, top_k=20, top_p=0.9, repetition_penalty=1.2, num_return_sequences=30, eos_token_id=0)
10
  i=0
11
  for seq in sequences:
12
  if (len(seq.get('generated_text')) == 108):
 
15
  if(i==6):
16
  return(poems)
17
 
18
+ textbox = gr.Textbox(label="输入0~5个汉字作为诗的开头,以英文空格分隔,最后一个字后面不用空格。一次生成六首诗,大概耗时15秒。(Enter 0~5 Chinese characters to be the beginning of the poem, separated by a space. )", placeholder="白 日 依 山 尽", lines=17)
19
 
20
  iface = gr.Interface(fn=poems, inputs=textbox, outputs="text")
21
  iface.launch()