okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
150c2394f
main
1"""OWN-5: one line per comparison in pics/cmp/*.json with its worst pair (lowest PSNR), and pics/index.html. 2python -I -B summarize.py <pics>""" 3import html 4import json 5import math 6import sys 7from pathlib import Path 8 9root = Path (sys .argv [1 ]) 10items = [] 11for f in sorted ((root / "cmp" ).glob ("*.json" )): 12d = json .loads (f .read_text ()) 13s ,pairs = d ["summary" ], [p for p in d ["pairs" ]if "error" not in p ] 14worst = min (pairs ,key = lambda p :p ["psnr_db" ])if pairs else None 15items .append ((s ,worst )) 16w = "-" if worst is None or math .isinf (worst ["psnr_db" ])else f" { worst [ 'name' ] } (PSNR { worst [ 'psnr_db' ]:.1f } , SSIM { worst [ 'ssim' ]:.3f } , max { worst [ 'max_abs' ]:.0f } )" 17f" { s [ 'label' ] } : { s [ 'bytes_equal' ] } / { s [ 'pairs' ] } identical; worst { w } " ) 18h = ["<!doctype html><meta charset=utf-8><title>OWN-5 same seed</title>" , 19"<style>body{font:14px sans-serif;margin:16px;max-width:1100px}li{margin:6px 0}</style>" , 20"<h1>OWN-5: the same seed, picture pairs</h1><p>Each link shows A | B | |A-B| x 8 for every pair, worst first is listed here.</p><ul>" ] 21for s ,w in items : 22ws = "" if w is None or math .isinf (w ["psnr_db" ])else f"; worst pair { w [ 'name' ] } : PSNR { w [ 'psnr_db' ]:.1f } dB, SSIM { w [ 'ssim' ]:.3f } " 23pm = s .get ("psnr_mean" ) 24h .append (f"<li><a href='cmp/ { html . escape ( s [ 'label' ]) } .html'> { html . escape ( s [ 'label' ]) } </a>: { s [ 'bytes_equal' ] } / { s [ 'pairs' ] } " 25f"byte-identical, mean |d| { s . get ( 'mean_abs' , 0 ):.2f } , PSNR mean { pm if pm is None or math . isinf ( pm ) else round ( pm , 1 ) } { ws } </li>" ) 26(root / "index.html" ).write_text ("\n" .join (h + ["</ul>" ]),encoding = "utf-8" )