File size: 886 Bytes
cad6bfa
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/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)