Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -50,6 +50,9 @@ if st.button("Predict Emotions") and selected_images:
|
|
50 |
# Predict emotion for each selected image using the pipeline
|
51 |
st.session_state['results'] = [pipe(image) for image in selected_images]
|
52 |
|
|
|
|
|
|
|
53 |
# Generate DataFrame from results
|
54 |
if st.button("Generate HeatMap & DataFrame"):
|
55 |
# Access the results, image names, and sizes from the session state
|
@@ -113,7 +116,7 @@ if st.button("Generate HeatMap & DataFrame"):
|
|
113 |
)
|
114 |
|
115 |
# Save the DataFrame to an Excel file with images
|
116 |
-
if st.button("Save to Excel"):
|
117 |
# Create a new Excel writer object
|
118 |
writer = pd.ExcelWriter('emotion_scores.xlsx', engine='xlsxwriter')
|
119 |
df_emotions.to_excel(writer, index=False)
|
|
|
50 |
# Predict emotion for each selected image using the pipeline
|
51 |
st.session_state['results'] = [pipe(image) for image in selected_images]
|
52 |
|
53 |
+
# Initialize an empty DataFrame outside of the button press condition
|
54 |
+
df_emotions = pd.DataFrame()
|
55 |
+
|
56 |
# Generate DataFrame from results
|
57 |
if st.button("Generate HeatMap & DataFrame"):
|
58 |
# Access the results, image names, and sizes from the session state
|
|
|
116 |
)
|
117 |
|
118 |
# Save the DataFrame to an Excel file with images
|
119 |
+
if st.button("Save to Excel") and not df_emotions.empty:
|
120 |
# Create a new Excel writer object
|
121 |
writer = pd.ExcelWriter('emotion_scores.xlsx', engine='xlsxwriter')
|
122 |
df_emotions.to_excel(writer, index=False)
|