kinensake commited on
Commit
c4bf747
·
1 Parent(s): 0afc4d0

Fix: session state

Browse files
Files changed (1) hide show
  1. app.py +10 -7
app.py CHANGED
@@ -21,9 +21,9 @@ def loadEnModel():
21
  class GramformerDemo:
22
 
23
  def __init__(self):
24
- if 'models_loaded' not in st.session_state:
25
- st.session_state['models_loaded'] = False
26
-
27
  st.set_page_config(
28
  page_title="Gramformer Demo",
29
  initial_sidebar_state="expanded",
@@ -124,10 +124,13 @@ class GramformerDemo:
124
  st.warning('TO BE IMPLEMENTED !!')
125
  st.stop()
126
 
127
- with st.spinner('Loading model..'):
128
- if not st.session_state['models_loaded']:
129
- loadEnModel()
130
- gf = self.load_gf(self.model_map[model_type])
 
 
 
131
 
132
  input_text = st.selectbox(
133
  label="Choose an example",
 
21
  class GramformerDemo:
22
 
23
  def __init__(self):
24
+ if 'gf' not in st.session_state:
25
+ st.session_state['gf'] = None
26
+
27
  st.set_page_config(
28
  page_title="Gramformer Demo",
29
  initial_sidebar_state="expanded",
 
124
  st.warning('TO BE IMPLEMENTED !!')
125
  st.stop()
126
 
127
+ if not st.session_state['gf']:
128
+ with st.spinner('Loading model..'):
129
+ loadEnModel()
130
+ gf = self.load_gf(self.model_map[model_type])
131
+ st.session_state['gf'] = gf
132
+ else:
133
+ gf = st.session_state['gf']
134
 
135
  input_text = st.selectbox(
136
  label="Choose an example",