nafisehNik commited on
Commit
6e99ada
1 Parent(s): 64f4b37
Files changed (2) hide show
  1. .streamlit/config.toml +6 -0
  2. app.py +16 -2
.streamlit/config.toml ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ [theme]
2
+ primaryColor="#FF8000"
3
+ #backgroundColor="#FFFFFF"
4
+ #secondaryBackgroundColor="#F0F2F6"
5
+ #textColor="#262730"
6
+ #font="sans serif"
app.py CHANGED
@@ -5,8 +5,22 @@ from transformers import AutoModelForSeq2SeqLM, MT5Tokenizer
5
  st.set_page_config(layout="wide", page_title="MT5 Persian Summary")
6
 
7
 
8
- fine = AutoModelForSeq2SeqLM.from_pretrained('nafisehNik/mt5-persian-summary')
9
- tokenizer = MT5Tokenizer.from_pretrained("nafisehNik/mt5-persian-summary")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
 
11
 
12
  # method for summary generation, using the global model and tokenizer
 
5
  st.set_page_config(layout="wide", page_title="MT5 Persian Summary")
6
 
7
 
8
+ # Load model lazily
9
+ @st.cache(allow_output_mutation=True)
10
+ def load_model():
11
+ model = AutoModelForSeq2SeqLM.from_pretrained('nafisehNik/mt5-persian-summary')
12
+ return model
13
+
14
+ # Load tokenizer lazily
15
+ @st.cache(allow_output_mutation=True)
16
+ def load_tokenizer():
17
+ tokenizer = MT5Tokenizer.from_pretrained("nafisehNik/mt5-persian-summary")
18
+ return tokenizer
19
+
20
+ with st.spinner(text="Please wait while the model is loading...."):
21
+ # cache
22
+ fine = load_model()
23
+ tokenizer = load_tokenizer()
24
 
25
 
26
  # method for summary generation, using the global model and tokenizer