import os import json def reconstruct_file(index_file, output_file): with open(index_file, 'r') as f: shards = json.load(f) with open(output_file, 'wb') as output: for shard in shards: with open(shard, 'rb') as part: output.write(part.read()) index_file = 'model.safetensors.index.json' output_file = 'reconstructed_model.safetensors' reconstruct_file(index_file, output_file)