"""Rebuild standard exports from the evaluated TEM2 artifact.""" import json import struct from pathlib import Path import numpy as np import torch from tinyemo.model import TinyEmo, TinyEmoConfig from tinyemo.runtime import TinyEmoRuntime HERE = Path(__file__).resolve().parent rt = TinyEmoRuntime(str(HERE / 'tiny_emo.bin')) model = TinyEmo(TinyEmoConfig(**rt.meta)) model.load_state_dict({k: torch.from_numpy(v.copy()) for k, v in rt.w.items()}) model.eval() (HERE / 'config.json').write_text(json.dumps({'model_type': 'tinyemo', 'architecture': 'TinyEmo', 'config': rt.meta, 'labels': rt.labels}, ensure_ascii=False, indent=2) + '\n') # Safetensors: 8-byte header length, JSON header, then contiguous little-endian data. tensors = {k: v.detach().cpu().numpy().astype('