Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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(
|
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: {
|
|
|
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'}")
|