xtlyxt commited on
Commit
3dbcc1d
·
verified ·
1 Parent(s): 8f3f272

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -8
app.py CHANGED
@@ -2,8 +2,8 @@ import streamlit as st
2
  from PIL import Image
3
  from transformers import pipeline
4
 
5
- # Create an image classification pipeline
6
- pipe = pipeline("image-classification", model="trpakov/vit-face-expression")
7
 
8
  # Define emotion labels
9
  emotion_labels = ["Happy", "Sad", "Angry", "Surprised", "Neutral"]
@@ -28,9 +28,6 @@ if uploaded_image:
28
  st.image(image, caption=f"Predicted emotion: {predicted_emotion}", use_column_width=True)
29
 
30
  # Display scores for each category
31
- if "scores" in results[0]:
32
- st.write("Emotion Scores:")
33
- for label, score in zip(emotion_labels, results[0]["scores"]):
34
- st.write(f"{label}: {score:.4f}")
35
- else:
36
- st.write("Emotion scores not available for this prediction.")
 
2
  from PIL import Image
3
  from transformers import pipeline
4
 
5
+ # Create an image classification pipeline with scores
6
+ pipe = pipeline("image-classification", model="trpakov/vit-face-expression", return_all_scores=True)
7
 
8
  # Define emotion labels
9
  emotion_labels = ["Happy", "Sad", "Angry", "Surprised", "Neutral"]
 
28
  st.image(image, caption=f"Predicted emotion: {predicted_emotion}", use_column_width=True)
29
 
30
  # Display scores for each category
31
+ st.write("Emotion Scores:")
32
+ for label, score in zip(emotion_labels, results[0]["scores"]):
33
+ st.write(f"{label}: {score:.4f}")