sebtick commited on
Commit
57784e6
·
verified ·
1 Parent(s): 991ed79

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -4
app.py CHANGED
@@ -41,11 +41,11 @@ def load_model():
41
 
42
  classifier = load_model()
43
 
44
- # --- Initialiser session_state pour historique ---
45
  if 'history' not in st.session_state:
46
  st.session_state.history = []
47
 
48
- # --- Fonction pour colorer les barres ---
49
  def sentiment_color(score):
50
  red = int(255 * (1 - score))
51
  green = int(255 * score)
@@ -85,7 +85,7 @@ if st.button("🔎 Analyser"):
85
  results.append(result_entry)
86
  st.session_state.history.append(result_entry)
87
 
88
- # Réactions
89
  if "negative" in sentiment.lower():
90
  st.toast("🚨 Sentiment négatif détecté !", icon="⚡")
91
  st.error(f"😞 Texte : {phrase}")
@@ -95,6 +95,16 @@ if st.button("🔎 Analyser"):
95
  else:
96
  st.warning(f"😐 Texte : {phrase}")
97
 
 
 
 
 
 
 
 
 
 
 
98
  # Barre colorée de score
99
  color = sentiment_color(score)
100
  st.markdown(
@@ -114,7 +124,7 @@ if st.session_state.history:
114
  df_history = pd.DataFrame(st.session_state.history)
115
  st.dataframe(df_history)
116
 
117
- # Bouton pour télécharger l'historique
118
  csv = df_history.to_csv(index=False)
119
  buffer = io.BytesIO()
120
  buffer.write(csv.encode())
 
41
 
42
  classifier = load_model()
43
 
44
+ # --- Initialiser l'historique ---
45
  if 'history' not in st.session_state:
46
  st.session_state.history = []
47
 
48
+ # --- Fonction pour la couleur de la barre ---
49
  def sentiment_color(score):
50
  red = int(255 * (1 - score))
51
  green = int(255 * score)
 
85
  results.append(result_entry)
86
  st.session_state.history.append(result_entry)
87
 
88
+ # Réactions selon le sentiment
89
  if "negative" in sentiment.lower():
90
  st.toast("🚨 Sentiment négatif détecté !", icon="⚡")
91
  st.error(f"😞 Texte : {phrase}")
 
95
  else:
96
  st.warning(f"😐 Texte : {phrase}")
97
 
98
+ # Explication du slider
99
+ st.markdown(
100
+ """
101
+ <p style="margin-top:20px; text-align:center;">
102
+ <em>Le score de confiance indique la certitude du modèle concernant l'émotion détectée. Plus le score est élevé, plus la prédiction est fiable.</em>
103
+ </p>
104
+ """,
105
+ unsafe_allow_html=True
106
+ )
107
+
108
  # Barre colorée de score
109
  color = sentiment_color(score)
110
  st.markdown(
 
124
  df_history = pd.DataFrame(st.session_state.history)
125
  st.dataframe(df_history)
126
 
127
+ # Bouton pour télécharger l'historique en CSV
128
  csv = df_history.to_csv(index=False)
129
  buffer = io.BytesIO()
130
  buffer.write(csv.encode())