Gladiator commited on
Commit
8809824
1 Parent(s): 6bfd2d5

cache abs summarizer

Browse files
Files changed (1) hide show
  1. app.py +12 -8
app.py CHANGED
@@ -10,12 +10,13 @@ from src.abstractive_summarizer import (
10
  preprocess_text_for_abstractive_summarization,
11
  )
12
 
13
- # # abstractive summarizer model
14
- # @st.cache()
15
- # def load_abs_model():
16
- # tokenizer = T5Tokenizer.from_pretrained("t5-base")
17
- # model = T5ForConditionalGeneration.from_pretrained("t5-base")
18
- # return tokenizer, model
 
19
 
20
 
21
  if __name__ == "__main__":
@@ -73,8 +74,11 @@ if __name__ == "__main__":
73
  text="Creating abstractive summary. This might take a few seconds ..."
74
  ):
75
  text_to_summarize = clean_txt
76
- abs_summarizer = pipeline(
77
- "summarization", model=abs_model_name, tokenizer=abs_tokenizer_name
 
 
 
78
  )
79
  if is_url is False:
80
  # list of chunks
 
10
  preprocess_text_for_abstractive_summarization,
11
  )
12
 
13
+
14
+ @st.cache()
15
+ def load_abs_summarizer(model_name, tokenizer_name):
16
+ abs_summarizer = pipeline(
17
+ "summarization", model=model_name, tokenizer=tokenizer_name
18
+ )
19
+ return abs_summarizer
20
 
21
 
22
  if __name__ == "__main__":
 
74
  text="Creating abstractive summary. This might take a few seconds ..."
75
  ):
76
  text_to_summarize = clean_txt
77
+ # abs_summarizer = pipeline(
78
+ # "summarization", model=abs_model_name, tokenizer=abs_tokenizer_name
79
+ # )
80
+ abs_summarizer = load_abs_summarizer(
81
+ model_name=abs_model_name, tokenizer_name=abs_tokenizer_name
82
  )
83
  if is_url is False:
84
  # list of chunks