xtlyxt commited on
Commit
e116055
·
verified ·
1 Parent(s): ea68c20

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -27
app.py CHANGED
@@ -151,45 +151,30 @@ else:
151
 
152
 
153
 
154
- st.write("selected_images inner loop:", selected_images)
155
- st.write("selected_file_names inner loop:", selected_file_names)
156
- st.write("results inner loop:", results)
157
 
158
 
159
-
160
  # Generate DataFrame button
161
  if st.button("Generate DataFrame") and selected_images:
162
  # Create a list to store data for DataFrame
163
  df_data = []
164
 
165
  # Iterate through selected images to gather data
166
- for image, file_name, result in zip(selected_images, selected_file_names, results):
167
- # Extract image metadata
168
-
169
- #st.write("selected_images inner loop:", selected_images)
170
- #st.write("selected_file_names inner loop:", selected_file_names)
171
- #st.write("results inner loop:", results)
172
-
173
- size_kb = image.size[0] * image.size[1] / 1024.0 # Calculating size in KB
174
- timestamp = datetime.datetime.now() # Current timestamp
175
- color_type = "Color" if image.mode == 'RGB' else "Grayscale"
176
-
177
  # Extract predicted emotions and scores
178
  emotion_scores = {res["label"].split("_")[-1].capitalize(): res["score"] for res in result}
179
 
180
- # Append image metadata and emotion scores to the list
181
  df_data.append({
182
- "Neutral": f"{emotion_scores.get('neutral', 0.0):.4f}",
183
- "Happy": f"{emotion_scores.get('happy', 0.0):.4f}",
184
- "Sad": f"{emotion_scores.get('sad', 0.0):.4f}",
185
- "Angry": f"{emotion_scores.get('angry', 0.0):.4f}",
186
- "Disgust": f"{emotion_scores.get('disgust', 0.0):.4f}",
187
- "Surprise": f"{emotion_scores.get('surprise', 0.0):.4f}",
188
- "Fear": f"{emotion_scores.get('fear', 0.0):.4f}", # Add this line if 'Fear' is a possible label
189
- "File Name": file_name,
190
- "Size (KB)": size_kb,
191
- "Timestamp": timestamp.strftime('%Y-%m-%d %H:%M:%S'), # Format timestamp
192
- "Color Type": color_type
193
  })
194
 
195
  # Create DataFrame
 
151
 
152
 
153
 
154
+ st.write("selected_images info:", selected_images)
155
+ st.write("selected_file_names info:", selected_file_names)
156
+ st.write("results info:", results)
157
 
158
 
 
159
  # Generate DataFrame button
160
  if st.button("Generate DataFrame") and selected_images:
161
  # Create a list to store data for DataFrame
162
  df_data = []
163
 
164
  # Iterate through selected images to gather data
165
+ for result in results:
 
 
 
 
 
 
 
 
 
 
166
  # Extract predicted emotions and scores
167
  emotion_scores = {res["label"].split("_")[-1].capitalize(): res["score"] for res in result}
168
 
169
+ # Append emotion scores to the list
170
  df_data.append({
171
+ "Neutral": f"{emotion_scores.get('Neutral', 0.0):.4f}",
172
+ "Happy": f"{emotion_scores.get('Happy', 0.0):.4f}",
173
+ "Sad": f"{emotion_scores.get('Sad', 0.0):.4f}",
174
+ "Angry": f"{emotion_scores.get('Angry', 0.0):.4f}",
175
+ "Disgust": f"{emotion_scores.get('Disgust', 0.0):.4f}",
176
+ "Surprise": f"{emotion_scores.get('Surprise', 0.0):.4f}",
177
+ "Fear": f"{emotion_scores.get('Fear', 0.0):.4f}" # Add this line if 'Fear' is a possible label
 
 
 
 
178
  })
179
 
180
  # Create DataFrame