Process and print evaluation results with rich formatting.
(self, preds: Dict, accs: defaultdict)
| 147 | return self.judge.generate_content([video, prompt]) |
| 148 | |
| 149 | def process_results(self, preds: Dict, accs: defaultdict) -> float: |
| 150 | """Process and print evaluation results with rich formatting.""" |
| 151 | num_insts = len(preds) |
| 152 | total_score = 0 |
| 153 | |
| 154 | category_mapping = { |
| 155 | 2: [("framewise", "temporal")], |
| 156 | 5: [("newton", "mass", "fluid", "penetration", "gravity")] |
| 157 | } |
| 158 | |
| 159 | for category, scores in accs.items(): |
| 160 | self.printer.print_header(f"{category.replace('_', ' ').title()} Details") |
| 161 | num_sub = len(scores) // num_insts |
| 162 | |
| 163 | if num_sub == 1: |
| 164 | overall = np.mean(scores) |
| 165 | self.printer.print_score("Overall", overall) |
| 166 | total_score += overall |
| 167 | elif num_sub in category_mapping: |
| 168 | sub_scores = {} |
| 169 | for i, sub in enumerate(category_mapping[num_sub][0]): |
| 170 | sub_mean = np.mean(scores[i::num_sub]) |
| 171 | sub_scores[sub.title()] = sub_mean |
| 172 | |
| 173 | # Create and display results table |
| 174 | table = self.printer.create_results_table( |
| 175 | category.replace('_', ' ').title(), |
| 176 | sub_scores |
| 177 | ) |
| 178 | self.printer.console.print(table) |
| 179 | |
| 180 | overall = np.sum(list(sub_scores.values())) |
| 181 | self.printer.print_score("Overall", overall, indent=2) |
| 182 | total_score += overall |
| 183 | else: |
| 184 | raise ValueError(f"Unexpected number of subcategories: {num_sub}") |
| 185 | |
| 186 | self.printer.print_summary_panel(total_score, len(accs)) |
| 187 | return total_score |
| 188 | |
| 189 | |
| 190 | def save_results(results: Dict, save_path: str): |
no test coverage detected