今天在用Python实现前端跟后端的数据交换,结果出现了这个bug。原因就是json不认numpy的array,所以可以把psnr_list直接作为list传入,不用转为array.
# run test and set results
file_name = 'conditional_gan.py'
if(os.path.getsize(save_path)==0):
t = threading.Thread(target=run_python, args=(test_path,file_name))
t.start()
# read txt file, get corresponding psnr value for each generated .hdr
psnr_list = []
with open(os.path.join(save_path, 'psnr.txt'),'r') as f:
while True:
lines = f.readline() # 整行读取数据
if not lines:
break
if (lines[0] == 'b' or lines[0] == '\n'):
continue
_, E_tmp = [i for i in lines.split(':')] # 将整行数据分割处理,如果分割符是空格,括号里就不用传入参数,如果是逗号