| #!/usr/bin/env python3 | |
| """๋ชจ๋ธ ํ์ผ ๋ณต์ ์คํฌ๋ฆฝํธ""" | |
| import json, base64, glob, os, sys | |
| def reconstruct(hf_base, output_path=None): | |
| parts = sorted(glob.glob(f"{hf_base}.part*.json")) | |
| if not parts: | |
| print(f"ํ์ผ ์์: {hf_base}.part*.json") | |
| return | |
| if output_path is None: | |
| output_path = hf_base | |
| os.makedirs(os.path.dirname(output_path) or ".", exist_ok=True) | |
| with open(output_path, "wb") as out: | |
| for p in parts: | |
| with open(p) as f: | |
| chunk_data = json.load(f) | |
| out.write(base64.b64decode(chunk_data["data"])) | |
| print(f" {p} โ OK") | |
| print(f"๋ณต์ ์๋ฃ: {output_path}") | |
| if __name__ == "__main__": | |
| base = sys.argv[1] if len(sys.argv) > 1 else "models/cropdoc_efficientnet_v2/model.pt" | |
| out = sys.argv[2] if len(sys.argv) > 2 else base | |
| reconstruct(base, out) | |