Download scripts/pack.py from WeReCooking/LookAnything-ONNX-WebGPU: direct link, hf CLI and curl.
- Browser
- Download file 1.25 kB
-
https://huggingface.co/WeReCooking/LookAnything-ONNX-WebGPU/resolve/main/scripts/pack.py
- Command line
-
hf download hf://WeReCooking/LookAnything-ONNX-WebGPU/scripts/pack.py
-
curl -L -o pack.py https://huggingface.co/WeReCooking/LookAnything-ONNX-WebGPU/resolve/main/scripts/pack.py
1.25 kB
| """Re-save the quantized parts as single .onnx files (no external data) and write manifest.json. | |
| usage: pack.py Q8_DIR FP32_DIR DATA_DIR OUT_DIR | |
| Q8_DIR quantize.py output (vis_a vis_b lm_1..4); FP32_DIR export_look.py output (heads, query_tokens.f32) | |
| DATA_DIR make_data.py output (prompt.json, ids.json, prompt_rows.bf16)""" | |
| import hashlib, json, os, shutil, sys | |
| import onnx | |
| q8, fp32, data, out = sys.argv[1:5] | |
| os.makedirs(out, exist_ok=True) | |
| files = {} | |
| for p in ("vis_a", "vis_b", "lm_1", "lm_2", "lm_3", "lm_4", "heads"): | |
| src = f"{q8}/{p}/{p}.onnx" if p != "heads" else f"{fp32}/heads/heads.onnx" | |
| onnx.save_model(onnx.load(src), f"{out}/{p}.onnx") | |
| files[p] = {"path": f"{p}.onnx", "bytes": os.path.getsize(f"{out}/{p}.onnx"), "sha256": hashlib.sha256(open(f"{out}/{p}.onnx", "rb").read()).hexdigest()} | |
| extra = {} | |
| for name, d in (("prompt.json", data), ("ids.json", data), ("prompt_rows.bf16", data), ("query_tokens.f32", fp32)): | |
| shutil.copy(f"{d}/{name}", f"{out}/{name}"); extra[name] = {"path": name, "bytes": os.path.getsize(f"{out}/{name}")} | |
| json.dump({"format": 1, "files": files, "data": extra, "order": list(files), "total_bytes": sum(f["bytes"] for f in files.values())}, open(f"{out}/manifest.json", "w"), indent=1) | |