llmahmad commited on
Commit
c4f6d26
·
verified ·
1 Parent(s): c71f04f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -1
app.py CHANGED
@@ -12,7 +12,14 @@ model = BartForConditionalGeneration.from_pretrained(model_name)
12
 
13
  def summarize_text(text):
14
  inputs = tokenizer(text, return_tensors="pt", truncation=True, padding="longest")
15
- summary_ids = model.generate(inputs["input_ids"], max_length=150, min_length=30, do_sample=False)
 
 
 
 
 
 
 
16
  summary = tokenizer.decode(summary_ids[0], skip_special_tokens=True)
17
  return summary
18
 
@@ -29,3 +36,16 @@ if st.button("Summarize"):
29
  else:
30
  st.warning("Please enter some text to summarize.")
31
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
 
13
  def summarize_text(text):
14
  inputs = tokenizer(text, return_tensors="pt", truncation=True, padding="longest")
15
+ summary_ids = model.generate(
16
+ inputs["input_ids"],
17
+ max_length=150,
18
+ min_length=30,
19
+ length_penalty=2.0,
20
+ num_beams=4,
21
+ early_stopping=True
22
+ )
23
  summary = tokenizer.decode(summary_ids[0], skip_special_tokens=True)
24
  return summary
25
 
 
36
  else:
37
  st.warning("Please enter some text to summarize.")
38
 
39
+ if __name__ == "__main__":
40
+ st.set_option('deprecation.showfileUploaderEncoding', False)
41
+ st.markdown(
42
+ """
43
+ <style>
44
+ .reportview-container {
45
+ flex-direction: row;
46
+ justify-content: center.
47
+ }
48
+ </style>
49
+ """,
50
+ unsafe_allow_html=True
51
+ )