Fix: session state
Browse files
app.py
CHANGED
@@ -21,9 +21,9 @@ def loadEnModel():
|
|
21 |
class GramformerDemo:
|
22 |
|
23 |
def __init__(self):
|
24 |
-
if '
|
25 |
-
|
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 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
|
|
|
|
|
|
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",
|