deep-learning-analytics commited on
Commit
d0f63c1
1 Parent(s): 02a0fc5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -8,9 +8,9 @@ model = T5ForConditionalGeneration.from_pretrained('deep-learning-analytics/Gram
8
 
9
  def correct_grammar(input_text,num_return_sequences=1):
10
  batch = tokenizer([input_text],truncation=True,padding='max_length',max_length=64, return_tensors="pt").to(torch_device)
11
- translated = model.generate(**batch,max_length=64,num_beams=2, num_return_sequences=num_return_sequences, temperature=1.5)
12
- tgt_text = tokenizer.batch_decode(translated, skip_special_tokens=True)
13
- return tgt_text
14
 
15
- iface = gr.Interface(fn=correct_grammar, inputs=[gr.inputs.Textbox(lines=5)],outputs=["text"])
16
  iface.launch(inline=False, share=True)
 
8
 
9
  def correct_grammar(input_text,num_return_sequences=1):
10
  batch = tokenizer([input_text],truncation=True,padding='max_length',max_length=64, return_tensors="pt").to(torch_device)
11
+ results = model.generate(**batch,max_length=64,num_beams=2, num_return_sequences=num_return_sequences, temperature=1.5)
12
+ answer = tokenizer.batch_decode(results[0], skip_special_tokens=True)
13
+ return answer
14
 
15
+ iface = gr.Interface(fn=correct_grammar, inputs=[gr.inputs.Textbox(lines=5)], outputs=["text"])
16
  iface.launch(inline=False, share=True)