xtlyxt commited on
Commit
b2d76e0
·
verified ·
1 Parent(s): 2622d4f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -4
app.py CHANGED
@@ -53,17 +53,16 @@ if st.button("Predict Emotions") and selected_images:
53
  label = res["label"]
54
  score = res["score"]
55
  col.write(f"{label}: {score:.4f}")
56
-
57
  else:
58
  # Predict emotion for each selected image using the pipeline
59
  results = [pipe(image) for image in selected_images]
60
 
61
  # Display images and predicted emotions
62
- for i, result in enumerate(results):
63
  predicted_class = result[0]["label"]
64
  predicted_emotion = predicted_class.split("_")[-1].capitalize()
65
- st.image(selected_images[i], caption=f"Predicted emotion: {predicted_emotion}", use_column_width=True)
66
  st.write(f"Emotion Scores for #{i+1} Image")
67
  st.write(f"{predicted_emotion}: {result[0]['score']:.4f}")
68
  # Use the index to get the corresponding filename
69
- st.write(f"Original File Name: {selected_images[i].filename}")
 
53
  label = res["label"]
54
  score = res["score"]
55
  col.write(f"{label}: {score:.4f}")
 
56
  else:
57
  # Predict emotion for each selected image using the pipeline
58
  results = [pipe(image) for image in selected_images]
59
 
60
  # Display images and predicted emotions
61
+ for i, (image, result) in enumerate(zip(selected_images, results)):
62
  predicted_class = result[0]["label"]
63
  predicted_emotion = predicted_class.split("_")[-1].capitalize()
64
+ st.image(image, caption=f"Predicted emotion: {predicted_emotion}", use_column_width=True)
65
  st.write(f"Emotion Scores for #{i+1} Image")
66
  st.write(f"{predicted_emotion}: {result[0]['score']:.4f}")
67
  # Use the index to get the corresponding filename
68
+ st.write(f"Original File Name: {uploaded_images[i].name if i < len(uploaded_images) else 'Unknown'}")