xtlyxt commited on
Commit
fb4f062
·
verified ·
1 Parent(s): 6d9b955

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -1
app.py CHANGED
@@ -51,4 +51,22 @@ if st.button("Predict Emotions") and selected_images:
51
  st.write("Keys and Values of all results:")
52
  col1, col2 = st.columns(2)
53
  for i, result in enumerate(results):
54
- col = col1 if i == 0 else
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51
  st.write("Keys and Values of all results:")
52
  col1, col2 = st.columns(2)
53
  for i, result in enumerate(results):
54
+ col = col1 if i == 0 else col2
55
+ col.write(f"Keys and Values of results[{i}]:")
56
+ for res in result:
57
+ label = res["label"]
58
+ score = res["score"]
59
+ col.write(f"{label}: {score:.4f}")
60
+
61
+ else:
62
+ # Predict emotion for each selected image using the pipeline
63
+ results = [pipe(image) for image in selected_images]
64
+
65
+ # Display images and predicted emotions
66
+ for i, result in enumerate(results):
67
+ predicted_class = result[0]["label"]
68
+ predicted_emotion = predicted_class.split("_")[-1].capitalize()
69
+ st.image(selected_images[i], caption=f"Predicted emotion: {predicted_emotion}", use_column_width=True)
70
+ st.write(f"Emotion Scores for #{i+1} Image")
71
+ st.write(f"{predicted_emotion}: {result[0]['score']:.4f}")
72
+ st.write(f"Original File Name: {uploaded_images[i].name}") # Display original file name