Build the full evaluation report.
(model_name, query_tags, per_scene_results, checkpoint=None, resolution=None, model_params=None)
| 75 | |
| 76 | |
| 77 | def build_report(model_name, query_tags, per_scene_results, checkpoint=None, resolution=None, model_params=None): |
| 78 | """Build the full evaluation report.""" |
| 79 | report = { |
| 80 | "meta": { |
| 81 | "model": model_name, |
| 82 | "checkpoint": checkpoint or "", |
| 83 | "query": query_tags or "all", |
| 84 | "resolution": list(resolution) if resolution else [], |
| 85 | "num_scenes": len(per_scene_results), |
| 86 | "timestamp": datetime.now().isoformat(), |
| 87 | "model_params": model_params or {}, |
| 88 | }, |
| 89 | "per_scene": per_scene_results, |
| 90 | } |
| 91 | |
| 92 | # Overall aggregation |
| 93 | ALL_METRIC_TYPES = ["depth_metric", "depth", "tgm", "camera", "trajectory", "pointcloud", "pointcloud_gt_pose", "pointcloud_pred_pose"] |
| 94 | report["aggregate"] = {} |
| 95 | for metric_type in ALL_METRIC_TYPES: |
| 96 | dicts = [r[metric_type] for r in per_scene_results if metric_type in r] |
| 97 | if dicts: |
| 98 | report["aggregate"][metric_type] = aggregate_metric_dict(dicts) |
| 99 | |
| 100 | # Group by source_dataset |
| 101 | by_dataset = defaultdict(list) |
| 102 | for r in per_scene_results: |
| 103 | by_dataset[r.get("source_dataset", "unknown")].append(r) |
| 104 | |
| 105 | report["per_dataset_breakdown"] = {} |
| 106 | for ds, results in by_dataset.items(): |
| 107 | breakdown = {"num_scenes": len(results)} |
| 108 | for metric_type in ALL_METRIC_TYPES: |
| 109 | dicts = [r[metric_type] for r in results if metric_type in r] |
| 110 | if dicts: |
| 111 | breakdown[metric_type] = aggregate_metric_dict(dicts) |
| 112 | report["per_dataset_breakdown"][ds] = breakdown |
| 113 | |
| 114 | # Group by each tag value |
| 115 | by_tag = defaultdict(list) |
| 116 | for r in per_scene_results: |
| 117 | for axis, value in r.get("tags", {}).items(): |
| 118 | by_tag[value].append(r) |
| 119 | |
| 120 | report["per_tag_breakdown"] = {} |
| 121 | for tag_value, results in by_tag.items(): |
| 122 | breakdown = {"num_scenes": len(results)} |
| 123 | for metric_type in ALL_METRIC_TYPES: |
| 124 | dicts = [r[metric_type] for r in results if metric_type in r] |
| 125 | if dicts: |
| 126 | breakdown[metric_type] = aggregate_metric_dict(dicts) |
| 127 | report["per_tag_breakdown"][tag_value] = breakdown |
| 128 | |
| 129 | # Efficiency statistics |
| 130 | timings = [r.get("timing", {}).get("inference_seconds", 0) for r in per_scene_results] |
| 131 | if timings: |
| 132 | report["efficiency"] = { |
| 133 | "mean_inference_seconds": float(np.mean(timings)), |
| 134 | "total_inference_seconds": float(np.sum(timings)), |
no test coverage detected