怎么调用其中的infer函数
def real_infer_one_img(im):
infer_result = exe.run(
inference_program,
feed={feed_target_names[0]: im},
fetch_list=fetch_targets)
# print(infer_result)
# 打印预测结果
mini_batch_result = np.argsort(infer_result) # 找出可能性最大的列标,升序排列
# print(mini_batch_result.shape)
mini_batch_result = mini_batch_result[0][:, -TOP_K:] # 把这些列标拿出来
mini_batch_result = mini_batch_result.flatten() #拉平了,只吐出一个 array
mini_batch_result = mini_batch_result[::-1] #逆序
return mini_batch_result
def infer(file_path):
im = process_image(file_path)
result = real_infer_one_img(im)
result = convert_list(result)
return result