Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -148,6 +148,7 @@ else:
|
|
148 |
st.error("Results list is empty.")
|
149 |
|
150 |
|
|
|
151 |
# Generate DataFrame button
|
152 |
if st.button("Generate DataFrame") and selected_images:
|
153 |
# Create a list to store data for DataFrame
|
@@ -158,7 +159,7 @@ if st.button("Generate DataFrame") and selected_images:
|
|
158 |
# Extract image metadata
|
159 |
size_kb = image.size[0] * image.size[1] / 1024.0 # Calculating size in KB
|
160 |
timestamp = datetime.datetime.now() # Current timestamp
|
161 |
-
color_type = "Color" if
|
162 |
|
163 |
# Extract predicted emotions and scores
|
164 |
emotion_scores = {res["label"].split("_")[-1].capitalize(): res["score"] for res in result}
|
@@ -171,10 +172,10 @@ if st.button("Generate DataFrame") and selected_images:
|
|
171 |
"Angry": f"{emotion_scores.get('Angry', 0.0):.4f}",
|
172 |
"Disgust": f"{emotion_scores.get('Disgust', 0.0):.4f}",
|
173 |
"Surprise": f"{emotion_scores.get('Surprise', 0.0):.4f}",
|
174 |
-
"Fear": f"{emotion_scores.get('Fear', 0.0):.4f}",
|
175 |
"File Name": file_name,
|
176 |
"Size (KB)": size_kb,
|
177 |
-
"Timestamp": timestamp,
|
178 |
"Color Type": color_type
|
179 |
})
|
180 |
|
@@ -183,3 +184,4 @@ if st.button("Generate DataFrame") and selected_images:
|
|
183 |
|
184 |
# Display DataFrame
|
185 |
st.write(df)
|
|
|
|
148 |
st.error("Results list is empty.")
|
149 |
|
150 |
|
151 |
+
|
152 |
# Generate DataFrame button
|
153 |
if st.button("Generate DataFrame") and selected_images:
|
154 |
# Create a list to store data for DataFrame
|
|
|
159 |
# Extract image metadata
|
160 |
size_kb = image.size[0] * image.size[1] / 1024.0 # Calculating size in KB
|
161 |
timestamp = datetime.datetime.now() # Current timestamp
|
162 |
+
color_type = "Color" if image.mode == 'RGB' else "Grayscale"
|
163 |
|
164 |
# Extract predicted emotions and scores
|
165 |
emotion_scores = {res["label"].split("_")[-1].capitalize(): res["score"] for res in result}
|
|
|
172 |
"Angry": f"{emotion_scores.get('Angry', 0.0):.4f}",
|
173 |
"Disgust": f"{emotion_scores.get('Disgust', 0.0):.4f}",
|
174 |
"Surprise": f"{emotion_scores.get('Surprise', 0.0):.4f}",
|
175 |
+
"Fear": f"{emotion_scores.get('Fear', 0.0):.4f}", # Add this line if 'Fear' is a possible label
|
176 |
"File Name": file_name,
|
177 |
"Size (KB)": size_kb,
|
178 |
+
"Timestamp": timestamp.strftime('%Y-%m-%d %H:%M:%S'), # Format timestamp
|
179 |
"Color Type": color_type
|
180 |
})
|
181 |
|
|
|
184 |
|
185 |
# Display DataFrame
|
186 |
st.write(df)
|
187 |
+
|