Spaces:
Runtime error
Runtime error
Commit
•
3b5bd24
1
Parent(s):
f384719
Update caption translation logic
Browse files- apps/mlm.py +4 -4
apps/mlm.py
CHANGED
@@ -109,21 +109,21 @@ def app(state):
|
|
109 |
|
110 |
# Display caption
|
111 |
new_col2.write("Write your text with exactly one [MASK] token.")
|
112 |
-
caption = new_col2.text_input(
|
113 |
label="Text",
|
114 |
value=mlm_state.caption,
|
115 |
help="Type your masked caption regarding the image above in one of the four languages.",
|
116 |
)
|
117 |
|
118 |
-
if
|
119 |
new_col2.markdown("**Masked Token**: "+mlm_state.currently_masked_token)
|
120 |
new_col2.markdown("**English Translation: " + mlm_state.unmasked_caption if mlm_state.caption_lang_id == "en" else translate(mlm_state.unmasked_caption, 'en'))
|
121 |
|
122 |
else:
|
123 |
new_col2.markdown(
|
124 |
-
f"""**English Translation**: {caption if mlm_state.caption_lang_id == "en" else translate(caption, 'en')}"""
|
125 |
)
|
126 |
-
caption_inputs = get_text_attributes(caption)
|
127 |
|
128 |
# Display Top-5 Predictions
|
129 |
with st.spinner("Predicting..."):
|
|
|
109 |
|
110 |
# Display caption
|
111 |
new_col2.write("Write your text with exactly one [MASK] token.")
|
112 |
+
mlm_state.caption = new_col2.text_input(
|
113 |
label="Text",
|
114 |
value=mlm_state.caption,
|
115 |
help="Type your masked caption regarding the image above in one of the four languages.",
|
116 |
)
|
117 |
|
118 |
+
if mlm_state.unmasked_caption == mlm_state.caption.replace("[MASK]", mlm_state.currently_masked_token):
|
119 |
new_col2.markdown("**Masked Token**: "+mlm_state.currently_masked_token)
|
120 |
new_col2.markdown("**English Translation: " + mlm_state.unmasked_caption if mlm_state.caption_lang_id == "en" else translate(mlm_state.unmasked_caption, 'en'))
|
121 |
|
122 |
else:
|
123 |
new_col2.markdown(
|
124 |
+
f"""**English Translation**: {mlm_state.caption if mlm_state.caption_lang_id == "en" else translate(mlm_state.caption, 'en')}"""
|
125 |
)
|
126 |
+
caption_inputs = get_text_attributes(mlm_state.caption)
|
127 |
|
128 |
# Display Top-5 Predictions
|
129 |
with st.spinner("Predicting..."):
|