当前位置:网站首页>Modify the VOT2018.json file and remove the color in the image path

Modify the VOT2018.json file and remove the color in the image path

2022-08-09 11:44:00 anonymous magician

Upload the code directly

import jsonimport os, sysjson_path = 'VOT2018.json'new_json_path = 'VOT2018_new.json'txt_path = 'list.txt'dict = {}def get_json_data(path): # Modify and delete the color in the original json filewith open(path) as f:params = json.load(f)file = open('list.txt')while 1 :lines = file.readline(1000)if not lines:breaklines = lines[:-1] # Get the name of each video folderroot = (params[lines]['img_names'])for i in range(len(root)):kind, color, jpg = root[i].split('/') # example kind :'ants1', color: 'color' , jpg :'00000001.jpg'root[i] = kind + '/' + jpg # rewrite the path, remove colorfile.close()dict = params# print(dict)f.close()return dictdef write_json_data(path, dictionary): # savewith open(path, 'w') as r:json.dump(dictionary, r)r.close()if __name__ == '__main__':dictionary = get_json_data(json_path)write_json_data(new_json_path, dictionary)

OK

原网站

版权声明
本文为[anonymous magician]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/221/202208091132073004.html