kcarnold commited on
Commit
92076bd
·
verified ·
1 Parent(s): 76b5bb9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
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
- html = ''
93
  for span in spans:
94
  b = int(256 * span["token_loss"] / highest_loss)
95
- html += f'<span style="color: rgba(128, 128, {b:d})" title="{html.escape(span["most_likely_token"])}">{html.escape(span["token"])}</span>'
96
- html = f"<p style=\"background: white;\">{html}</p>"
97
 
98
  st.subheader("Rewritten document")
99
- st.write(html, unsafe_allow_html=True)
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']])