| |
| """ |
| 汇总 DeCLIP 消融实验结果 |
| |
| 生成包含以下内容的 Excel 表格: |
| 1. 各消融实验的最佳结果 (按 novel_ap50) |
| 2. 与基线 (CLIPSelf, ClearCLIP) 的对比 |
| 3. 各 epoch 的详细结果 |
| """ |
|
|
| import os |
| import pandas as pd |
|
|
| |
|
|
| |
| JEPA_GSC_RESULTS = { |
| 'experiment': 'JEPA-GSC', |
| 'description': 'Using I-JEPA as Global Scene Context instead of DINOv2', |
| 'backbone': 'EVA02-CLIP-B-16', |
| 'epochs': { |
| 1: {'base_ap50': 50.953, 'novel_ap50': 37.065, 'all_ap50': 47.321, 'bbox_mAP': 0.230}, |
| 2: {'base_ap50': 54.300, 'novel_ap50': 39.589, 'all_ap50': 50.453, 'bbox_mAP': 0.270}, |
| 3: {'base_ap50': 56.357, 'novel_ap50': 38.061, 'all_ap50': 51.572, 'bbox_mAP': 0.286}, |
| } |
| } |
|
|
| |
| SAM_GSC_RESULTS = { |
| 'experiment': 'SAM-GSC', |
| 'description': 'Using SAM as Global Scene Context instead of DINOv2', |
| 'backbone': 'EVA02-CLIP-B-16', |
| 'epochs': { |
| 1: {'base_ap50': 50.557, 'novel_ap50': 36.800, 'all_ap50': 46.959, 'bbox_mAP': 0.233}, |
| 2: {'base_ap50': 54.251, 'novel_ap50': 37.820, 'all_ap50': 49.954, 'bbox_mAP': 0.267}, |
| 3: {'base_ap50': 56.274, 'novel_ap50': 37.691, 'all_ap50': 51.414, 'bbox_mAP': 0.283}, |
| } |
| } |
|
|
| |
| BASELINE_RESULTS = { |
| 'CLIPSelf': { |
| 'description': 'CLIPSelf with DINOv2-GSC (Base, Ensemble)', |
| 'base_ap50': 54.94, |
| 'novel_ap50': 37.51, |
| 'all_ap50': 50.38, |
| 'bbox_mAP': 0.277, |
| }, |
| } |
|
|
|
|
| def get_best_epoch(results, metric='novel_ap50'): |
| """获取指定指标最高的 epoch""" |
| best_epoch = None |
| best_value = -1 |
| for epoch, metrics in results['epochs'].items(): |
| if metrics[metric] > best_value: |
| best_value = metrics[metric] |
| best_epoch = epoch |
| return best_epoch, results['epochs'][best_epoch] |
|
|
|
|
| def generate_summary_excel(output_path): |
| """生成汇总 Excel 表格""" |
| |
| with pd.ExcelWriter(output_path, engine='openpyxl') as writer: |
| |
| |
| rows = [] |
| |
| |
| for exp_results in [JEPA_GSC_RESULTS, SAM_GSC_RESULTS]: |
| best_epoch, best_metrics = get_best_epoch(exp_results, 'novel_ap50') |
| rows.append({ |
| 'Model': exp_results['experiment'], |
| 'Description': exp_results['description'], |
| 'Best Epoch': best_epoch, |
| 'base_ap50': best_metrics['base_ap50'], |
| 'novel_ap50': best_metrics['novel_ap50'], |
| 'all_ap50': best_metrics['all_ap50'], |
| 'bbox_mAP': best_metrics['bbox_mAP'] * 100, |
| }) |
| |
| df_summary = pd.DataFrame(rows) |
| df_summary.to_excel(writer, sheet_name='Best Results', index=False) |
| |
| |
| jepa_rows = [] |
| for epoch, metrics in JEPA_GSC_RESULTS['epochs'].items(): |
| jepa_rows.append({ |
| 'Epoch': epoch, |
| 'base_ap50': metrics['base_ap50'], |
| 'novel_ap50': metrics['novel_ap50'], |
| 'all_ap50': metrics['all_ap50'], |
| 'bbox_mAP': metrics['bbox_mAP'] * 100, |
| }) |
| df_jepa = pd.DataFrame(jepa_rows) |
| df_jepa.to_excel(writer, sheet_name='JEPA-GSC All Epochs', index=False) |
| |
| |
| sam_rows = [] |
| for epoch, metrics in SAM_GSC_RESULTS['epochs'].items(): |
| sam_rows.append({ |
| 'Epoch': epoch, |
| 'base_ap50': metrics['base_ap50'], |
| 'novel_ap50': metrics['novel_ap50'], |
| 'all_ap50': metrics['all_ap50'], |
| 'bbox_mAP': metrics['bbox_mAP'] * 100, |
| }) |
| df_sam = pd.DataFrame(sam_rows) |
| df_sam.to_excel(writer, sheet_name='SAM-GSC All Epochs', index=False) |
| |
| print(f"Excel saved to: {output_path}") |
|
|
|
|
| def print_summary(): |
| """打印汇总信息""" |
| print("=" * 80) |
| print("DeCLIP Ablation Experiments Summary") |
| print("=" * 80) |
| |
| print("\n--- Ablation Experiments (Best by novel_ap50) ---") |
| for exp_results in [JEPA_GSC_RESULTS, SAM_GSC_RESULTS]: |
| best_epoch, best_metrics = get_best_epoch(exp_results, 'novel_ap50') |
| print(f"{exp_results['experiment']} (Epoch {best_epoch}): " |
| f"base_ap50={best_metrics['base_ap50']:.2f}, " |
| f"novel_ap50={best_metrics['novel_ap50']:.2f}, " |
| f"all_ap50={best_metrics['all_ap50']:.2f}") |
| |
| print("=" * 80) |
|
|
|
|
| if __name__ == '__main__': |
| import argparse |
| parser = argparse.ArgumentParser(description='Summarize DeCLIP ablation experiments') |
| parser.add_argument('--output', type=str, |
| default='/mnt/bn/strategy-mllm-train/user/wangjunjie/code/xiaomoguhzz/DeCLIP_private/ablation_experiments/ablation_summary.xlsx', |
| help='Output Excel file path') |
| args = parser.parse_args() |
| |
| print_summary() |
| generate_summary_excel(args.output) |
|
|