wiraindrak commited on
Commit
d8843f7
·
1 Parent(s): c7ea66e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -13
app.py CHANGED
@@ -7,22 +7,23 @@ tokenizer_t5 = T5Tokenizer.from_pretrained("panggi/t5-base-indonesian-summarizat
7
  model_t5 = T5ForConditionalGeneration.from_pretrained("panggi/t5-base-indonesian-summarization-cased")
8
 
9
  def summ_t5(text):
10
- input_ids = tokenizer.encode(text, return_tensors='pt')
11
- summary_ids = model_.generate(input_ids,
12
- max_length=100,
13
- num_beams=2,
14
- repetition_penalty=2.5,
15
- length_penalty=1.0,
16
- early_stopping=True,
17
- no_repeat_ngram_size=2,
18
- use_cache=True)
19
- summary_text = tokenizer_t5.decode(summary_ids[0], skip_special_tokens=True)
20
- return summary_text
21
-
22
  summ_demo = gr.Interface(
23
  fn=summ_t5,
24
  inputs="text",
25
- outputs="text")
 
26
 
27
  if __name__ == "__main__":
28
  Parallel(summ_demo,
 
7
  model_t5 = T5ForConditionalGeneration.from_pretrained("panggi/t5-base-indonesian-summarization-cased")
8
 
9
  def summ_t5(text):
10
+ input_ids = tokenizer_t5.encode(text, return_tensors='pt')
11
+ summary_ids = model_t5.generate(input_ids,
12
+ max_length=100,
13
+ num_beams=2,
14
+ repetition_penalty=2.5,
15
+ length_penalty=1.0,
16
+ early_stopping=True,
17
+ no_repeat_ngram_size=2,
18
+ use_cache=True)
19
+ summary_text = tokenizer_t5.decode(summary_ids[0], skip_special_tokens=True)
20
+ return summary_text
21
+
22
  summ_demo = gr.Interface(
23
  fn=summ_t5,
24
  inputs="text",
25
+ outputs=gr.Textbox(lines=10, label="T5 Base Output")
26
+ )
27
 
28
  if __name__ == "__main__":
29
  Parallel(summ_demo,