Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -16,14 +16,17 @@ st.write(f"{x} squared is {x * x}")
|
|
16 |
uploaded_images = st.file_uploader("Upload images", type=["jpg", "png"], accept_multiple_files=True)
|
17 |
|
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 |
-
|
25 |
-
|
26 |
-
|
|
|
|
|
|
|
|
|
27 |
|
28 |
if st.button("Predict Emotions") and selected_images:
|
29 |
if len(selected_images) == 2:
|
@@ -62,4 +65,4 @@ if st.button("Predict Emotions") and selected_images:
|
|
62 |
st.image(selected_images[i], caption=f"Predicted emotion: {predicted_emotion}", use_column_width=True)
|
63 |
st.write(f"Emotion Scores for #{i+1} Image")
|
64 |
st.write(f"{predicted_emotion}: {result[0]['score']:.4f}")
|
65 |
-
st.write(f"Original File Name: {
|
|
|
16 |
uploaded_images = st.file_uploader("Upload images", type=["jpg", "png"], accept_multiple_files=True)
|
17 |
|
18 |
# Display thumbnail images alongside file names and sizes in the sidebar
|
|
|
19 |
if uploaded_images:
|
20 |
for img in uploaded_images:
|
21 |
image = Image.open(img)
|
22 |
+
st.sidebar.image(image, caption=f"{img.name} {img.size / 1024.0:.1f} KB", width=40)
|
23 |
+
|
24 |
+
# Collect selected images based on checkbox input
|
25 |
+
selected_images = []
|
26 |
+
for img in uploaded_images:
|
27 |
+
selected = st.sidebar.checkbox(f"{img.name} {img.size / 1024.0:.1f} KB", value=False, key=img.name)
|
28 |
+
if selected:
|
29 |
+
selected_images.append(Image.open(img))
|
30 |
|
31 |
if st.button("Predict Emotions") and selected_images:
|
32 |
if len(selected_images) == 2:
|
|
|
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 |
+
st.write(f"Original File Name: {uploaded_images[i].name}") # Display original file name
|