zjuJish's picture
Upload layer_diff_dataset/change_json.py with huggingface_hub
db9ad34 verified
raw
history blame
679 Bytes
import json
# 需要将这些路径前缀替换为新的路径前缀
old_prefix = "/mnt/workgroup_a100/yunfei.wj/AIGC/dataset/DIS5K/DIS5K/DIS-TR"
new_prefix = "/mnt/workspace/workgroup/sihui.jsh/layer_diff_dataset/train"
# 读取原始JSON文件
# 修改每个字典的"images"和"images_rgba"字段
for item in data:
item["images"] = item["images"].replace(old_prefix, new_prefix)
item["images_rgba"] = item["images_rgba"].replace(old_prefix, new_prefix)
# 写入新的JSON文件
with open('/mnt/workspace/workgroup/sihui.jsh/layer_diff_dataset/im_rgba.json', 'w') as file:
json.dump(data, file, indent=4)
print("New JSON file has been created successfully.")