swcrazyfan commited on
Commit
a198a6a
1 Parent(s): b47bcd2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -3
app.py CHANGED
@@ -21,15 +21,18 @@ def tokenize_data(text, dekingify):
21
  return inputs
22
 
23
  def generate_answers(text, max_length, num_beams, dekingify):
 
24
  inputs = tokenize_data(text, dekingify)
25
  results= model.generate(input_ids= inputs['input_ids'], attention_mask=inputs['attention_mask'], do_sample=True,
26
- num_beams=num_beams,
27
- max_length=max_length,
28
  min_length=1,
29
  early_stopping=True,
30
  num_return_sequences=1)
31
  answer = tokenizer.decode(results[0], skip_special_tokens=True)
32
  return answer
33
 
34
- iface = gr.Interface(title="Kingify 2Way", description="Write anything below. Then, click submit to 'DeKingify' it.", fn=generate_answers, inputs=[gr.inputs.Textbox(label="Original Text",lines=10), gr.inputs.Slider(label="Maximum Length", minimum=1, maximum=512, default=512, step=1), gr.inputs.Slider(label="Number of Beams", minimum=1, maximum=10, default=5, step=1), gr.inputs.Radio(label="What do you want to do?", choices=["Kingify", "Dekingify"])], outputs=["text"])
 
 
35
  iface.launch(inline=False)
 
21
  return inputs
22
 
23
  def generate_answers(text, max_length, num_beams, dekingify):
24
+ def generate_answers(text, dekingify):
25
  inputs = tokenize_data(text, dekingify)
26
  results= model.generate(input_ids= inputs['input_ids'], attention_mask=inputs['attention_mask'], do_sample=True,
27
+ num_beams=2,
28
+ max_length=512,
29
  min_length=1,
30
  early_stopping=True,
31
  num_return_sequences=1)
32
  answer = tokenizer.decode(results[0], skip_special_tokens=True)
33
  return answer
34
 
35
+ #iface = gr.Interface(title="Kingify 2Way", description="Write anything below. Then, click submit to 'DeKingify' it.", fn=generate_answers, inputs=[gr.inputs.Textbox(label="Original Text",lines=10), gr.inputs.Slider(label="Maximum Length", minimum=1, maximum=512, default=512, step=1), gr.inputs.Slider(label="Number of Beams", minimum=1, maximum=10, default=5, step=1), gr.inputs.Radio(label="What do you want to do?", choices=["Kingify", "Dekingify"])], outputs=["text"])
36
+
37
+ iface = gr.Interface(title="Kingify 2Way", description="Write anything below. Then, click submit to 'DeKingify' it.", fn=generate_answers, inputs=[gr.inputs.Textbox(label="Original Text",lines=10), gr.inputs.Radio(label="What do you want to do?", choices=["Kingify", "Dekingify"])], outputs=["text"])
38
  iface.launch(inline=False)