Spaces:
Runtime error
Runtime error
gchhablani
commited on
Commit
•
4bb9586
1
Parent(s):
0fc5212
Add filled sentence to MLM
Browse files- apps/mlm.py +3 -1
apps/mlm.py
CHANGED
@@ -130,7 +130,9 @@ def app(state):
|
|
130 |
scores = predict(transformed_image, dict(caption_inputs))
|
131 |
scores = softmax(scores)
|
132 |
labels, values = get_top_5_predictions(scores)
|
133 |
-
|
|
|
|
|
134 |
# newer_col1, newer_col2 = st.beta_columns([6,4])
|
135 |
fig = plotly_express_horizontal_bar_plot(values, labels)
|
136 |
st.dataframe(pd.DataFrame({"Tokens":labels, "English Translation": list(map(lambda x: translate(x),labels))}).T)
|
|
|
130 |
scores = predict(transformed_image, dict(caption_inputs))
|
131 |
scores = softmax(scores)
|
132 |
labels, values = get_top_5_predictions(scores)
|
133 |
+
filled_sentence = mlm_state.caption.replace("[MASK]", labels[0])
|
134 |
+
st.write("Filled Sentence: " + filled_sentence)
|
135 |
+
st.write( f"""**English Translation**: {translate(filled_sentence, 'en')}""")
|
136 |
# newer_col1, newer_col2 = st.beta_columns([6,4])
|
137 |
fig = plotly_express_horizontal_bar_plot(values, labels)
|
138 |
st.dataframe(pd.DataFrame({"Tokens":labels, "English Translation": list(map(lambda x: translate(x),labels))}).T)
|