SuveenE commited on
Commit
48fae9a
·
1 Parent(s): 563ac2e

UI updates

Browse files
Files changed (1) hide show
  1. app.py +28 -22
app.py CHANGED
@@ -117,8 +117,31 @@ def fetch_stats_for_selected(selected_datasets: List[str], progress=gr.Progress(
117
  except Exception as e:
118
  errors.append(f"❌ {repo_id}: Error - {str(e)}")
119
 
120
- # Build output
121
- output = [f"## Total Episodes: {total_episodes}\n"]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
122
 
123
  # Display v3 datasets grouped by date
124
  if v3_by_date:
@@ -128,19 +151,6 @@ def fetch_stats_for_selected(selected_datasets: List[str], progress=gr.Progress(
128
  if 'unknown' in v3_by_date:
129
  sorted_dates.append('unknown')
130
 
131
- def format_duration(seconds):
132
- """Format duration as hours, minutes, seconds"""
133
- hours = int(seconds // 3600)
134
- minutes = int((seconds % 3600) // 60)
135
- secs = int(seconds % 60)
136
-
137
- if hours > 0:
138
- return f"{hours}h {minutes}m {secs}s"
139
- elif minutes > 0:
140
- return f"{minutes}m {secs}s"
141
- else:
142
- return f"{secs}s"
143
-
144
  for date_key in sorted_dates:
145
  datasets = v3_by_date[date_key]
146
  date_display = datasets[0]['date_display']
@@ -157,7 +167,7 @@ def fetch_stats_for_selected(selected_datasets: List[str], progress=gr.Progress(
157
  # Format total duration
158
  duration_str = f" • {format_duration(date_total_seconds)}"
159
 
160
- output.append(f"**{date_display}** — Total: **{date_total_episodes} episodes**{duration_str}")
161
 
162
  for dataset in sorted(datasets, key=lambda x: x['repo_id']):
163
  repo_name = dataset['repo_id'].split('/')[-1] # Just the dataset name
@@ -174,19 +184,15 @@ def fetch_stats_for_selected(selected_datasets: List[str], progress=gr.Progress(
174
  duration_seconds = total_frames / fps
175
  duration_str = f" • {format_duration(duration_seconds)}"
176
 
177
- output.append(f" `{repo_name}`: **{episodes} episodes**{duration_str}")
178
-
179
- output.append("") # Empty line between dates
180
 
181
  # Display non-v3 datasets
182
  if non_v3_results:
183
- output.append("### 📦 v2.1 Datasets\n")
184
  output.extend(non_v3_results)
185
- output.append("")
186
 
187
  # Display errors at the end
188
  if errors:
189
- output.append("### ⚠️ Errors\n")
190
  output.extend(errors)
191
 
192
  return "\n".join(output)
 
117
  except Exception as e:
118
  errors.append(f"❌ {repo_id}: Error - {str(e)}")
119
 
120
+ def format_duration(seconds):
121
+ """Format duration as hours, minutes, seconds"""
122
+ hours = int(seconds // 3600)
123
+ minutes = int((seconds % 3600) // 60)
124
+ secs = int(seconds % 60)
125
+
126
+ if hours > 0:
127
+ return f"{hours}h {minutes}m {secs}s"
128
+ elif minutes > 0:
129
+ return f"{minutes}m {secs}s"
130
+ else:
131
+ return f"{secs}s"
132
+
133
+ # Calculate total duration across all datasets
134
+ total_duration_seconds = 0
135
+ for datasets in v3_by_date.values():
136
+ for d in datasets:
137
+ info_meta = d['stats'].get('info_metadata', {})
138
+ if info_meta.get('total_frames'):
139
+ fps = info_meta.get('fps', 30)
140
+ total_duration_seconds += info_meta['total_frames'] / fps
141
+
142
+ # Build output with total episodes and duration
143
+ duration_display = f" • {format_duration(total_duration_seconds)}" if total_duration_seconds > 0 else ""
144
+ output = [f"## Total Episodes: {total_episodes}{duration_display}\n"]
145
 
146
  # Display v3 datasets grouped by date
147
  if v3_by_date:
 
151
  if 'unknown' in v3_by_date:
152
  sorted_dates.append('unknown')
153
 
 
 
 
 
 
 
 
 
 
 
 
 
 
154
  for date_key in sorted_dates:
155
  datasets = v3_by_date[date_key]
156
  date_display = datasets[0]['date_display']
 
167
  # Format total duration
168
  duration_str = f" • {format_duration(date_total_seconds)}"
169
 
170
+ output.append(f"\n**{date_display}** — Total: **{date_total_episodes} episodes**{duration_str}")
171
 
172
  for dataset in sorted(datasets, key=lambda x: x['repo_id']):
173
  repo_name = dataset['repo_id'].split('/')[-1] # Just the dataset name
 
184
  duration_seconds = total_frames / fps
185
  duration_str = f" • {format_duration(duration_seconds)}"
186
 
187
+ output.append(f"- `{repo_name}`: **{episodes} episodes**{duration_str}")
 
 
188
 
189
  # Display non-v3 datasets
190
  if non_v3_results:
 
191
  output.extend(non_v3_results)
 
192
 
193
  # Display errors at the end
194
  if errors:
195
+ output.append("\n### ⚠️ Errors")
196
  output.extend(errors)
197
 
198
  return "\n".join(output)