basiliskinstitute
commited on
Commit
•
c7a413d
1
Parent(s):
6caae7e
Upload reconstitute.py
Browse files- reconstitute.py +15 -0
reconstitute.py
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import json
|
3 |
+
|
4 |
+
def reconstruct_file(index_file, output_file):
|
5 |
+
with open(index_file, 'r') as f:
|
6 |
+
shards = json.load(f)
|
7 |
+
|
8 |
+
with open(output_file, 'wb') as output:
|
9 |
+
for shard in shards:
|
10 |
+
with open(shard, 'rb') as part:
|
11 |
+
output.write(part.read())
|
12 |
+
|
13 |
+
index_file = 'model.safetensors.index.json'
|
14 |
+
output_file = 'reconstructed_model.safetensors'
|
15 |
+
reconstruct_file(index_file, output_file)
|