Download scripts/reconstruct.py from noivan/cropdoc: direct link, hf CLI and curl.
- Browser
- Download file 886 Bytes
-
https://huggingface.co/noivan/cropdoc/resolve/770bd4e2f5f6d5c8b2ef2f239d2df030d790d18c/scripts/reconstruct.py
- Command line
-
hf download hf://noivan/cropdoc@770bd4e2f5f6d5c8b2ef2f239d2df030d790d18c/scripts/reconstruct.py
-
curl -L -o reconstruct.py https://huggingface.co/noivan/cropdoc/resolve/770bd4e2f5f6d5c8b2ef2f239d2df030d790d18c/scripts/reconstruct.py
886 Bytes
| #!/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) | |