Commit
·
8d75ccb
1
Parent(s):
fad2e05
Small improvement in the app (gauge for probability)
Browse files- 5_artefact_streamlit.py +17 -1
- requirements.txt +1 -0
5_artefact_streamlit.py
CHANGED
|
@@ -1,8 +1,10 @@
|
|
| 1 |
import pandas as pd
|
| 2 |
import numpy as np
|
|
|
|
| 3 |
import matplotlib.pyplot as plt
|
| 4 |
from sentence_transformers import SentenceTransformer
|
| 5 |
from tensorflow.keras.models import model_from_json
|
|
|
|
| 6 |
from PIL import Image
|
| 7 |
import streamlit as st
|
| 8 |
|
|
@@ -192,7 +194,21 @@ with st.expander('Input a sentence and check the probability of it being hateful
|
|
| 192 |
y_pred = loaded_model.predict(preprocessed_sentence)
|
| 193 |
percentage = y_pred[0][0] * 100
|
| 194 |
|
| 195 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 196 |
if y_pred[0][0] < 0.5:
|
| 197 |
st.write(f"Congrats, it's not hateful!!!")
|
| 198 |
else:
|
|
|
|
| 1 |
import pandas as pd
|
| 2 |
import numpy as np
|
| 3 |
+
import os
|
| 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 |
+
fig1 = go.Figure(go.Indicator(
|
| 199 |
+
mode = "gauge+number+delta",
|
| 200 |
+
value = y_pred[0][0],
|
| 201 |
+
delta = {'reference': 0.50},
|
| 202 |
+
gauge = {'axis': {'range': [None, 1]},
|
| 203 |
+
'steps' : [
|
| 204 |
+
{'range': [0, 0.5], 'color': "lightgray"},
|
| 205 |
+
{'range': [0.5, 0.75], 'color': "gray"}],
|
| 206 |
+
'threshold' : {'line': {'color': "red", 'width': 4}, 'thickness': 0.9, 'value': 0.5}},
|
| 207 |
+
domain = {'x': [0, 1], 'y': [0, 1]},
|
| 208 |
+
title = {'text': 'Probability of your sentence being hateful'}))
|
| 209 |
+
|
| 210 |
+
st.plotly_chart(fig1)
|
| 211 |
+
|
| 212 |
if y_pred[0][0] < 0.5:
|
| 213 |
st.write(f"Congrats, it's not hateful!!!")
|
| 214 |
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 |
+
plotly
|
| 8 |
Pillow
|