File size: 1,574 Bytes
ed2d911 | 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 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | #!/usr/bin/env python3
import json
import os
def extract_split_mapping():
"""从training_data_with_content_v2.json中提取split映射"""
input_file = "/home/v-meiszhang/amlt-project/respace/training_data_with_content_v2.json"
output_file = "/home/v-meiszhang/amlt-project/respace/split_mapping.json"
print(f"Reading from {input_file}...")
split_mapping = {}
with open(input_file, 'r') as f:
data = json.load(f)
print(f"Total entries in original file: {len(data.get('data', []))}")
for entry in data.get('data', []):
scene_id = entry.get('id')
split = entry.get('split')
if scene_id and split:
split_mapping[scene_id] = split
print(f"Extracted {len(split_mapping)} scene-to-split mappings")
# 统计split分布
split_counts = {}
for split in split_mapping.values():
split_counts[split] = split_counts.get(split, 0) + 1
print("Split distribution:")
for split, count in sorted(split_counts.items()):
print(f" {split}: {count}")
# 保存映射
mapping_data = {
"metadata": {
"total_scenes": len(split_mapping),
"split_distribution": split_counts,
"source_file": input_file
},
"mapping": split_mapping
}
with open(output_file, 'w') as f:
json.dump(mapping_data, f, indent=2)
print(f"Split mapping saved to {output_file}")
return split_mapping
if __name__ == "__main__":
extract_split_mapping()
|