Spaces:
Sleeping
Sleeping
zyu
commited on
Commit
·
3cb0c3e
1
Parent(s):
314e5c3
fix: resolved the issue that the input text disappears while generating translation for the first run.
Browse files
app.py
CHANGED
@@ -132,6 +132,11 @@ def get_translation_result():
|
|
132 |
return input_text_content, output_text_content
|
133 |
|
134 |
|
|
|
|
|
|
|
|
|
|
|
135 |
def main():
|
136 |
hold_deterministic(SEED)
|
137 |
config = load_json(DATASETS_MODEL_INFO_PATH)
|
@@ -200,7 +205,14 @@ def main():
|
|
200 |
disable = st.session_state.load_model_in_progress or st.session_state.translate_in_progress
|
201 |
input_text_content, output_text_content = get_translation_result()
|
202 |
|
203 |
-
input_text = st.text_area(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
204 |
|
205 |
msg_model = "Please confirm model selection via the \'Select Model\' Button first!" \
|
206 |
if st.session_state.model_state['current_config'] is None \
|
|
|
132 |
return input_text_content, output_text_content
|
133 |
|
134 |
|
135 |
+
def set_input_text_content():
|
136 |
+
if 'input_text' in st.session_state:
|
137 |
+
st.session_state.translation_result['input'] = st.session_state.input_text
|
138 |
+
|
139 |
+
|
140 |
def main():
|
141 |
hold_deterministic(SEED)
|
142 |
config = load_json(DATASETS_MODEL_INFO_PATH)
|
|
|
205 |
disable = st.session_state.load_model_in_progress or st.session_state.translate_in_progress
|
206 |
input_text_content, output_text_content = get_translation_result()
|
207 |
|
208 |
+
input_text = st.text_area(
|
209 |
+
"Enter Text",
|
210 |
+
input_text_content,
|
211 |
+
max_chars=MAX_INPUT_LEN,
|
212 |
+
disabled=disable,
|
213 |
+
key="input_text",
|
214 |
+
on_change=set_input_text_content,
|
215 |
+
)
|
216 |
|
217 |
msg_model = "Please confirm model selection via the \'Select Model\' Button first!" \
|
218 |
if st.session_state.model_state['current_config'] is None \
|