"""深度分析mAP50-95瓶颈:per-IoU threshold + per-size breakdown""" import sys, os os.chdir("/home/user/goat") sys.path.insert(0, "/home/user/goat") import numpy as np print("Importing YOLO...", flush=True) from ultralytics import YOLO print("Loading model...", flush=True) model = YOLO('runs/detect/Detection_experiments/v6_1_s_refined/weights/best.pt') print("Running val...", flush=True) results = model.val(data='Data/Detection_dataset/dataset.yaml', imgsz=1536, batch=2, verbose=False) print("mAP50: {:.4f}".format(results.box.map50), flush=True) print("mAP50-95: {:.4f}".format(results.box.map), flush=True) # Check available attributes attrs = [x for x in dir(results.box) if not x.startswith('_')] print("Available attrs: {}".format(attrs), flush=True) # Try per-threshold AP try: ap = results.box.ap print("ap shape: {}".format(ap.shape), flush=True) print("ap values: {}".format(ap), flush=True) except Exception as e: print("ap error: {}".format(e), flush=True) try: all_ap = results.box.all_ap print("all_ap shape: {}".format(all_ap.shape), flush=True) # all_ap is typically [num_classes, num_iou_thresholds] iou_thresholds = np.arange(0.5, 1.0, 0.05) for i, t in enumerate(iou_thresholds): if i < all_ap.shape[-1]: print(" IoU={:.2f}: AP={:.4f}".format(t, all_ap[0, i] if all_ap.ndim > 1 else all_ap[i]), flush=True) except Exception as e: print("all_ap error: {}".format(e), flush=True) print("\nDONE", flush=True)