Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -8,12 +8,9 @@ pipe = pipeline("image-classification", model="trpakov/vit-face-expression", top
|
|
8 |
# Streamlit app
|
9 |
st.title("Emotion Recognition with vit-face-expression")
|
10 |
|
11 |
-
# Slider for adjusting image size
|
12 |
-
image_size = st.slider('Adjust the image size', min_value=50, max_value=500, value=200)
|
13 |
-
|
14 |
# Slider example
|
15 |
-
x = st.slider('Select a value')
|
16 |
-
st.write(f"{x} squared is {x * x}")
|
17 |
|
18 |
# Upload images
|
19 |
uploaded_images = st.file_uploader("Upload images", type=["jpg", "png"], accept_multiple_files=True)
|
@@ -41,7 +38,7 @@ if st.button("Predict Emotions") and selected_images:
|
|
41 |
predicted_class = results[i][0]["label"]
|
42 |
predicted_emotion = predicted_class.split("_")[-1].capitalize()
|
43 |
col = col1 if i == 0 else col2
|
44 |
-
col.image(selected_images[i], caption=f"Predicted emotion: {predicted_emotion}", use_column_width=True
|
45 |
col.write(f"Emotion Scores: {predicted_emotion}: {results[i][0]['score']:.4f}")
|
46 |
# Use the index to get the corresponding filename
|
47 |
col.write(f"Original File Name: {uploaded_images[i].name}")
|
@@ -64,10 +61,8 @@ if st.button("Predict Emotions") and selected_images:
|
|
64 |
for i, (image, result) in enumerate(zip(selected_images, results)):
|
65 |
predicted_class = result[0]["label"]
|
66 |
predicted_emotion = predicted_class.split("_")[-1].capitalize()
|
67 |
-
st.image(image, caption=f"Predicted emotion: {predicted_emotion}", use_column_width=True
|
68 |
st.write(f"Emotion Scores for #{i+1} Image")
|
69 |
st.write(f"{predicted_emotion}: {result[0]['score']:.4f}")
|
70 |
# Use the index to get the corresponding filename
|
71 |
st.write(f"Original File Name: {uploaded_images[i].name if i < len(uploaded_images) else 'Unknown'}")
|
72 |
-
|
73 |
-
|
|
|
8 |
# Streamlit app
|
9 |
st.title("Emotion Recognition with vit-face-expression")
|
10 |
|
|
|
|
|
|
|
11 |
# Slider example
|
12 |
+
#x = st.slider('Select a value')
|
13 |
+
#st.write(f"{x} squared is {x * x}")
|
14 |
|
15 |
# Upload images
|
16 |
uploaded_images = st.file_uploader("Upload images", type=["jpg", "png"], accept_multiple_files=True)
|
|
|
38 |
predicted_class = results[i][0]["label"]
|
39 |
predicted_emotion = predicted_class.split("_")[-1].capitalize()
|
40 |
col = col1 if i == 0 else col2
|
41 |
+
col.image(selected_images[i], caption=f"Predicted emotion: {predicted_emotion}", use_column_width=True)
|
42 |
col.write(f"Emotion Scores: {predicted_emotion}: {results[i][0]['score']:.4f}")
|
43 |
# Use the index to get the corresponding filename
|
44 |
col.write(f"Original File Name: {uploaded_images[i].name}")
|
|
|
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'}")
|
|
|
|