"""Extract Krea 2's learned per-tap weighting (txtfusion.projector) from a checkpoint. Reads only the safetensors header + the one small tensor - it does NOT load the model. Reproduces model_prior.json so the 12 prior values are never a magic number: rerun against any Krea 2 checkpoint (e.g. a new version, or the 8B) to re-derive the prior for that model. Usage: python extract_model_prior.py --model /path/to/krea2_turbo_bf16.safetensors python extract_model_prior.py --model ... --write # update model_prior.json """ import argparse import array import json import struct from pathlib import Path HERE = Path(__file__).resolve().parent TENSOR = "txtfusion.projector.weight" def read_tensor(path, name): with open(path, "rb") as f: n = struct.unpack("