Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -89,12 +89,12 @@ highest_loss = max(span['token_loss'] for span in spans[1:])
|
|
89 |
for span in spans:
|
90 |
span['loss_ratio'] = span['token_loss'] / highest_loss
|
91 |
|
92 |
-
|
93 |
for span in spans:
|
94 |
b = int(256 * span["token_loss"] / highest_loss)
|
95 |
-
|
96 |
-
|
97 |
|
98 |
st.subheader("Rewritten document")
|
99 |
-
st.write(
|
100 |
st.write(pd.DataFrame(spans)[['token', 'token_loss', 'most_likely_token', 'loss_ratio']])
|
|
|
89 |
for span in spans:
|
90 |
span['loss_ratio'] = span['token_loss'] / highest_loss
|
91 |
|
92 |
+
html_out = ''
|
93 |
for span in spans:
|
94 |
b = int(256 * span["token_loss"] / highest_loss)
|
95 |
+
html_out += f'<span style="color: rgba(128, 128, {b:d})" title="{html.escape(span["most_likely_token"])}">{html.escape(span["token"])}</span>'
|
96 |
+
html_out = f"<p style=\"background: white;\">{html_out}</p>"
|
97 |
|
98 |
st.subheader("Rewritten document")
|
99 |
+
st.write(html_out, unsafe_allow_html=True)
|
100 |
st.write(pd.DataFrame(spans)[['token', 'token_loss', 'most_likely_token', 'loss_ratio']])
|