Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -18,9 +18,10 @@ uploaded_images = st.file_uploader("Upload images", type=["jpg", "png"], accept_
|
|
18 |
# Display thumbnail images alongside file names and sizes in the sidebar
|
19 |
selected_images = []
|
20 |
if uploaded_images:
|
21 |
-
for img in uploaded_images:
|
22 |
image = Image.open(img)
|
23 |
-
|
|
|
24 |
if selected:
|
25 |
selected_images.append(image)
|
26 |
|
@@ -37,7 +38,8 @@ if st.button("Predict Emotions") and selected_images:
|
|
37 |
col = col1 if i == 0 else col2
|
38 |
col.image(selected_images[i], caption=f"Predicted emotion: {predicted_emotion}", use_column_width=True)
|
39 |
col.write(f"Emotion Scores: {predicted_emotion}: {results[i][0]['score']:.4f}")
|
40 |
-
|
|
|
41 |
|
42 |
# Display the keys and values of all results
|
43 |
st.write("Keys and Values of all results:")
|
@@ -61,5 +63,5 @@ if st.button("Predict Emotions") and selected_images:
|
|
61 |
st.image(selected_images[i], caption=f"Predicted emotion: {predicted_emotion}", use_column_width=True)
|
62 |
st.write(f"Emotion Scores for #{i+1} Image")
|
63 |
st.write(f"{predicted_emotion}: {result[0]['score']:.4f}")
|
64 |
-
|
65 |
-
|
|
|
18 |
# Display thumbnail images alongside file names and sizes in the sidebar
|
19 |
selected_images = []
|
20 |
if uploaded_images:
|
21 |
+
for idx, img in enumerate(uploaded_images):
|
22 |
image = Image.open(img)
|
23 |
+
checkbox_key = f"{img.name}_checkbox_{idx}" # Unique key for each checkbox
|
24 |
+
selected = st.sidebar.checkbox(f"{img.name} {img.size / 1024.0:.1f} KB", value=False, key=checkbox_key)
|
25 |
if selected:
|
26 |
selected_images.append(image)
|
27 |
|
|
|
38 |
col = col1 if i == 0 else col2
|
39 |
col.image(selected_images[i], caption=f"Predicted emotion: {predicted_emotion}", use_column_width=True)
|
40 |
col.write(f"Emotion Scores: {predicted_emotion}: {results[i][0]['score']:.4f}")
|
41 |
+
# Use the index to get the corresponding filename
|
42 |
+
col.write(f"Original File Name: {uploaded_images[i].name}")
|
43 |
|
44 |
# Display the keys and values of all results
|
45 |
st.write("Keys and Values of all results:")
|
|
|
63 |
st.image(selected_images[i], caption=f"Predicted emotion: {predicted_emotion}", use_column_width=True)
|
64 |
st.write(f"Emotion Scores for #{i+1} Image")
|
65 |
st.write(f"{predicted_emotion}: {result[0]['score']:.4f}")
|
66 |
+
# Use the index to get the corresponding filename
|
67 |
+
st.write(f"Original File Name: {selected_images[i].filename}")
|