zjuJish commited on
Commit
db9ad34
·
verified ·
1 Parent(s): 0d513a2

Upload layer_diff_dataset/change_json.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. layer_diff_dataset/change_json.py +19 -0
layer_diff_dataset/change_json.py ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+
3
+ # 需要将这些路径前缀替换为新的路径前缀
4
+ old_prefix = "/mnt/workgroup_a100/yunfei.wj/AIGC/dataset/DIS5K/DIS5K/DIS-TR"
5
+ new_prefix = "/mnt/workspace/workgroup/sihui.jsh/layer_diff_dataset/train"
6
+
7
+ # 读取原始JSON文件
8
+
9
+
10
+ # 修改每个字典的"images"和"images_rgba"字段
11
+ for item in data:
12
+ item["images"] = item["images"].replace(old_prefix, new_prefix)
13
+ item["images_rgba"] = item["images_rgba"].replace(old_prefix, new_prefix)
14
+
15
+ # 写入新的JSON文件
16
+ with open('/mnt/workspace/workgroup/sihui.jsh/layer_diff_dataset/im_rgba.json', 'w') as file:
17
+ json.dump(data, file, indent=4)
18
+
19
+ print("New JSON file has been created successfully.")