|
@@ -58,8 +58,6 @@ def main():
|
|
result = []
|
|
result = []
|
|
i=0
|
|
i=0
|
|
count = len(input_data)
|
|
count = len(input_data)
|
|
- with open('/app/data.json', 'w') as json_file:
|
|
|
|
- json_file.write("")
|
|
|
|
|
|
|
|
for k,v in input_data.items():
|
|
for k,v in input_data.items():
|
|
v2 = np.array([v], dtype=np.float32)
|
|
v2 = np.array([v], dtype=np.float32)
|
|
@@ -68,14 +66,14 @@ def main():
|
|
predictor.run()
|
|
predictor.run()
|
|
# 获取输出
|
|
# 获取输出
|
|
output_data = output_handle.copy_to_cpu() # numpy.ndarray类型
|
|
output_data = output_handle.copy_to_cpu() # numpy.ndarray类型
|
|
- result.append(k + "\t" + output_data.tolist()[0])
|
|
|
|
|
|
+ result.append(k + "\t" + str(output_data.tolist()[0]))
|
|
i=i+1
|
|
i=i+1
|
|
if i % 1000 == 0:
|
|
if i % 1000 == 0:
|
|
print("write batch {}/{}".format(i, count))
|
|
print("write batch {}/{}".format(i, count))
|
|
|
|
|
|
json_data = json.dumps(result, indent=4) # indent参数用于美化输出,使其更易读
|
|
json_data = json.dumps(result, indent=4) # indent参数用于美化输出,使其更易读
|
|
# 写入文件
|
|
# 写入文件
|
|
- with open('/app/data.json', 'a') as json_file:
|
|
|
|
|
|
+ with open('/app/data.json', 'w') as json_file:
|
|
for s in result:
|
|
for s in result:
|
|
json_file.write(s + "\n")
|
|
json_file.write(s + "\n")
|
|
|
|
|