VOT数据集JSON文件路径改写脚本
由于VOT下载的VOT 数据集中有些json文件的路径中不包含color目录,因此改写一下文件路径。
同理,对于json等文件中,设计添加路径方式都可以就这个代码进行改动。
(上传以作mark,防止以后又得重写-.-)
import json
import os, sys
json_path = 'VOT2016.json'
json_path1 = 'VOT2016_1.json'
txt_path = 'list.txt'
dict = {}
def get_json_data(json_path):
with open(json_path) as f:
params = json.load(f)
# add '/color/'to the path
file = open("list.txt")
while 1:
lines = file.readlines(1000)
if not lines:
break
for line in lines:
line = line[:-1]
root = (params[line]["img_names"])
# print(len(root))
while 1:
for i in range(len(root)):
kind, jpg = root[i].split("/")
root[i] = kind + '/color/' + jpg
# print(root)
break
file.close()
# print("params",params)
dict = params
f.close()
return dict
def write_json_data(dict):
with open(json_path1,'w') as r:
json.dump(dict,r)
r.close()
if __name__ == "__main__":
the_revised_dict = get_json_data(json_path)
write_json_data(the_revised_dict)
版权声明:本文为weixin_42528734原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。