Palplatine commited on
Commit
e0a7610
1 Parent(s): aa4bd4b

Small changes to improve the app (gauge for probability)

Browse files
Files changed (2) hide show
  1. app.py +20 -1
  2. requirements.txt +2 -1
app.py CHANGED
@@ -4,6 +4,7 @@ import os
4
  import matplotlib.pyplot as plt
5
  from sentence_transformers import SentenceTransformer
6
  from tensorflow.keras.models import model_from_json
 
7
  from PIL import Image
8
  import streamlit as st
9
 
@@ -193,7 +194,25 @@ with st.expander('Input a sentence and check the probability of it being hateful
193
  y_pred = loaded_model.predict(preprocessed_sentence)
194
  percentage = y_pred[0][0] * 100
195
 
196
- st.write(f'Probability of being hateful: {round(percentage, 2)/100}')
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
197
  if y_pred[0][0] < 0.5:
198
  st.write(f"Congrats, it's not hateful!!!")
199
  else:
 
4
  import matplotlib.pyplot as plt
5
  from sentence_transformers import SentenceTransformer
6
  from tensorflow.keras.models import model_from_json
7
+ import plotly.graph_objects as go
8
  from PIL import Image
9
  import streamlit as st
10
 
 
194
  y_pred = loaded_model.predict(preprocessed_sentence)
195
  percentage = y_pred[0][0] * 100
196
 
197
+ # Scoreboard du prêt
198
+ col1, col2, col3, col4 = st.columns(4)
199
+
200
+ with col2:
201
+
202
+ fig1 = go.Figure(go.Indicator(
203
+ mode = "gauge+number+delta",
204
+ value = y_pred[0][0],
205
+ delta = {'reference': 0.50},
206
+ gauge = {'axis': {'range': [None, 1]},
207
+ 'steps' : [
208
+ {'range': [0, 0.5], 'color': "lightgray"},
209
+ {'range': [0.5, 0.75], 'color': "gray"}],
210
+ 'threshold' : {'line': {'color': "red", 'width': 4}, 'thickness': 0.9, 'value': 0.5}},
211
+ domain = {'x': [0, 1], 'y': [0, 1]},
212
+ title = {'text': 'Probability of your sentence being hateful'}))
213
+
214
+ st.plotly_chart(fig1)
215
+
216
  if y_pred[0][0] < 0.5:
217
  st.write(f"Congrats, it's not hateful!!!")
218
  else:
requirements.txt CHANGED
@@ -4,4 +4,5 @@ numpy
4
  matplotlib
5
  sentence_transformers
6
  tensorflow
7
- Pillow
 
 
4
  matplotlib
5
  sentence_transformers
6
  tensorflow
7
+ Pillow
8
+ plotly