mzltest commited on
Commit
758db94
1 Parent(s): 22f5479

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -2,7 +2,7 @@ import gradio as gr
2
  import subprocess
3
 
4
 
5
- def generate_text(length, prefix, temperature,batchsize,topk,topp,rep):
6
  # 构建命令行参数
7
  my_prefix = "--prefix=" + prefix + ","
8
  args = ["python", "generate.py", f"--length={int(length)}", f"--nsamples=1", f"--prefix={prefix}", f"--temperature={temperature}",f"--batch_size={int(batchsize)}",f"--topk={int(topk)}",f"--topp={topp}",f"--repetition_penalty={rep}"]
@@ -17,7 +17,7 @@ def generate_text(length, prefix, temperature,batchsize,topk,topp,rep):
17
  input_length = gr.Slider(label="生成文本长度", minimum=10, maximum=500, value=100,step=10)
18
  input_prefix = gr.Textbox(label="起始文本")
19
  input_temperature = gr.Slider(label="生成温度", minimum=0, maximum=2, value=1, step=0.01)
20
- input_batchsize = gr.Slider(label="生成的batch size", minimum=1, maximum=1, value=1,step=1)
21
  input_topk = gr.Slider(label="最高几选一", minimum=1, maximum=20, value=8, step=1)
22
  input_topp = gr.Slider(label="最高积累概率", minimum=0, maximum=2, value=0,step=0.01)
23
  input_repeat_penality = gr.Slider(label="重复罚值", minimum=0, maximum=2, value=1,step=0.01)
@@ -27,4 +27,4 @@ output_text = gr.Textbox(label="生成的文本")
27
  title = "GPT2中文文本生成器"
28
  description = "cpu推理约1s/字,温度太低基本是无意义字符"
29
 
30
- gr.Interface(fn=generate_text, inputs=[input_length, input_prefix, input_temperature,input_batchsize,input_topk,input_topp,input_repeat_penality], outputs=output_text, title=title, description=description).launch()
 
2
  import subprocess
3
 
4
 
5
+ def generate_text(length, prefix, temperature,topk,topp,rep):
6
  # 构建命令行参数
7
  my_prefix = "--prefix=" + prefix + ","
8
  args = ["python", "generate.py", f"--length={int(length)}", f"--nsamples=1", f"--prefix={prefix}", f"--temperature={temperature}",f"--batch_size={int(batchsize)}",f"--topk={int(topk)}",f"--topp={topp}",f"--repetition_penalty={rep}"]
 
17
  input_length = gr.Slider(label="生成文本长度", minimum=10, maximum=500, value=100,step=10)
18
  input_prefix = gr.Textbox(label="起始文本")
19
  input_temperature = gr.Slider(label="生成温度", minimum=0, maximum=2, value=1, step=0.01)
20
+ #input_batchsize = gr.Slider(label="生成的batch size", minimum=1, maximum=1, value=1,step=1)
21
  input_topk = gr.Slider(label="最高几选一", minimum=1, maximum=20, value=8, step=1)
22
  input_topp = gr.Slider(label="最高积累概率", minimum=0, maximum=2, value=0,step=0.01)
23
  input_repeat_penality = gr.Slider(label="重复罚值", minimum=0, maximum=2, value=1,step=0.01)
 
27
  title = "GPT2中文文本生成器"
28
  description = "cpu推理约1s/字,温度太低基本是无意义字符"
29
 
30
+ gr.Interface(fn=generate_text, inputs=[input_length, input_prefix, input_temperature,input_topk,input_topp,input_repeat_penality], outputs=output_text, title=title, description=description).launch()