- Engine build scripts (FP16/INT8) - Benchmark validation scripts - Result parsing and analysis tools - COCO dataset configuration
110 lines
3.5 KiB
Python
110 lines
3.5 KiB
Python
import re
|
|
import json
|
|
from pathlib import Path
|
|
from datetime import datetime
|
|
|
|
def parse_file(filepath):
|
|
with open(filepath, 'r', encoding='utf-8', errors='replace') as f:
|
|
content = f.read()
|
|
|
|
result = {'file': filepath}
|
|
|
|
# Speed
|
|
speed_match = re.search(r'Speed:\s*([\d.]+)ms\s+preprocess,\s*([\d.]+)ms\s+inference', content)
|
|
if speed_match:
|
|
result['preprocess'] = float(speed_match.group(1))
|
|
result['inference'] = float(speed_match.group(2))
|
|
result['fps'] = round(1000/float(speed_match.group(2)), 1)
|
|
|
|
# Overall
|
|
overall = re.search(r'^\s*all\s+\d+\s+\d+\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)', content, re.MULTILINE)
|
|
if overall:
|
|
result['P'] = float(overall.group(1))
|
|
result['R'] = float(overall.group(2))
|
|
result['mAP50'] = float(overall.group(3))
|
|
result['mAP50_95'] = float(overall.group(4))
|
|
|
|
# Person
|
|
person = re.search(r'^\s*person\s+\d+\s+\d+\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)', content, re.MULTILINE)
|
|
if person:
|
|
result['person'] = {
|
|
'P': float(person.group(1)), 'R': float(person.group(2)),
|
|
'AP50': float(person.group(3)), 'AP50_95': float(person.group(4))
|
|
}
|
|
|
|
# Vehicles (car)
|
|
car = re.search(r'^\s*car\s+\d+\s+\d+\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)', content, re.MULTILINE)
|
|
if car:
|
|
result['car'] = {
|
|
'P': float(car.group(1)), 'R': float(car.group(2)),
|
|
'AP50': float(car.group(3)), 'AP50_95': float(car.group(4))
|
|
}
|
|
|
|
return result
|
|
|
|
print("="*60)
|
|
print("YOLO11n INT8 640p vs FP16 480p Benchmark")
|
|
print("="*60)
|
|
print(f"Time: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}")
|
|
print()
|
|
|
|
# Parse both
|
|
int8 = parse_file('int8_640_results.txt')
|
|
fp16 = parse_file('fp16_480_results.txt')
|
|
|
|
# Summary table
|
|
print("-"*60)
|
|
print("1. Overall Performance")
|
|
print("-"*60)
|
|
print(f"{'Config':<15} {'mAP50-95':<12} {'mAP50':<12} {'Inf(ms)':<10} {'FPS':<10}")
|
|
print("-"*60)
|
|
|
|
for name, data in [("INT8_640p", int8), ("FP16_480p", fp16)]:
|
|
m = data.get('mAP50_95', 0)
|
|
m50 = data.get('mAP50', 0)
|
|
inf = data.get('inference', 0)
|
|
fps = data.get('fps', 0)
|
|
print(f"{name:<15} {m:<12.4f} {m50:<12.4f} {inf:<10.2f} {fps:<10.1f}")
|
|
|
|
print()
|
|
print("-"*60)
|
|
print("2. Person Detection (Class 0)")
|
|
print("-"*60)
|
|
print(f"{'Config':<15} {'P':<10} {'R':<10} {'AP50':<12} {'AP50-95':<12}")
|
|
print("-"*60)
|
|
|
|
for name, data in [("INT8_640p", int8), ("FP16_480p", fp16)]:
|
|
p = data.get('person', {}).get('P', 0)
|
|
r = data.get('person', {}).get('R', 0)
|
|
ap50 = data.get('person', {}).get('AP50', 0)
|
|
ap5095 = data.get('person', {}).get('AP50_95', 0)
|
|
print(f"{name:<15} {p:<10.3f} {r:<10.3f} {ap50:<12.4f} {ap5095:<12.4f}")
|
|
|
|
print()
|
|
print("-"*60)
|
|
print("3. Car Detection (Class 2)")
|
|
print("-"*60)
|
|
print(f"{'Config':<15} {'P':<10} {'R':<10} {'AP50':<12} {'AP50-95':<12}")
|
|
print("-"*60)
|
|
|
|
for name, data in [("INT8_640p", int8), ("FP16_480p", fp16)]:
|
|
p = data.get('car', {}).get('P', 0)
|
|
r = data.get('car', {}).get('R', 0)
|
|
ap50 = data.get('car', {}).get('AP50', 0)
|
|
ap5095 = data.get('car', {}).get('AP50_95', 0)
|
|
print(f"{name:<15} {p:<10.3f} {r:<10.3f} {ap50:<12.4f} {ap5095:<12.4f}")
|
|
|
|
print()
|
|
print("-"*60)
|
|
print("4. Speed Comparison")
|
|
print("-"*60)
|
|
for name, data in [("INT8_640p", int8), ("FP16_480p", fp16)]:
|
|
inf = data.get('inference', 0)
|
|
fps = data.get('fps', 0)
|
|
print(f" {name}: {inf:.2f}ms ({fps:.1f} FPS)")
|
|
|
|
print()
|
|
print("="*60)
|
|
print("Done!")
|
|
print("="*60)
|