def output_predict_test(true_depths, depths, images, filenames, depth_filenames, output_dir, current_test_number):
#print images.shape
print("output predict into %s" % output_dir)
if not gfile.Exists(output_dir):
gfile.MakeDirs(output_dir)
for i, (image, depth, true_depth, filename) in enumerate(zip(images, depths, true_depths, filenames)):
#print filenames
img_info = re.sub(r'/', '_', re.findall(r'data/[a-zA-Z0-9_]+/[a-zA-Z0-9_]+/[a-zA-Z0-9]+', filename)[0])[0]
pilimg = Image.fromarray(np.uint8(image))
image_name = "%s/%s_org.png" % (output_dir, img_info)
pilimg.save(image_name)
depth = depth.transpose(2, 0, 1)
if np.max(depth) != 0:
ra_depth = (depth/np.max(depth))*255.0
else:
ra_depth = depth*255.0
depth_pil = Image.fromarray(np.uint8(ra_depth[0]), mode="L")
depth_name = "%s/%s_dep.png" % (output_dir, img_info)
depth_pil.save(depth_name)
true_depth = true_depth.transpose(2, 0, 1)
if np.max(true_depth) != 0:
ra_true_depth = (true_depth/np.max(true_depth))*255.0
else:
ra_true_depth = true_depth*255.0
true_depth_pil = Image.fromarray(np.uint8(ra_true_depth[0]), mode="L")
true_depth_name = "%s/%s_ture.png" % (output_dir, img_info)
true_depth_pil.save(true_depth_name)
评论列表
文章目录