val_output_tmp = model_512.predict([ val_90d[:, ::img_scale_inv, ::img_scale_inv], val_0d[:, ::img_scale_inv, ::img_scale_inv], val_M45d[:, ::img_scale_inv, ::img_scale_inv] ], batch_size=1) if corner_code == "NE": val_output_tmp = np.rot90(val_output_tmp, axes=(2, 1)) elif corner_code == "SW": val_output_tmp = np.rot90(val_output_tmp, axes=(1, 2)) elif corner_code == "SE": val_output_tmp = np.rot90(val_output_tmp, k=2, axes=(2, 1)) runtime = time.clock() - start plt.imshow(val_output_tmp[0, :, :, 0]) plt.imsave( output_dir + sample + "_" + str(corner_coords[0]) + "_" + str(corner_coords[1]) + '.png', val_output_tmp[0, :, :, 0]) plt.show() print("runtime: %.5f(s)" % runtime) # save .pfm file pfm_path = output_dir + "pfms/" + sample + "_" + str( corner_coords[0]) + "_" + str(corner_coords[1]) + '.pfm' write_pfm(val_output_tmp[0, :, :, 0], pfm_path) print('pfm file saved in ' + pfm_path)
dummy = model_512.predict([dum, dum, dum, dum], batch_size=1) """ Depth Estimation """ for image_path in dir_LFimages: (val_90d, val_0d, val_45d, val_M45d) = make_multiinput(image_path, image_h, image_w, Setting02_AngualrViews) # print(val_90d.shape) # exit() start = time.time() # predict val_output_tmp = model_512.predict([ val_90d[:, ::img_scale_inv, ::img_scale_inv], val_0d[:, ::img_scale_inv, ::img_scale_inv], val_45d[:, ::img_scale_inv, ::img_scale_inv], val_M45d[:, ::img_scale_inv, ::img_scale_inv] ], batch_size=1) runtime = time.time() - start plt.imshow(val_output_tmp[0, :, :, 0]) print("runtime: %.5f(s)" % runtime) # save .pfm file write_pfm(val_output_tmp[0, :, :, 0], dir_output + '/%s.pfm' % (image_path.split('/')[-1])) print('pfm file saved in %s/%s.pfm' % (dir_output, image_path.split('/')[-1]))
show_warped(Warped[:, :, 0]) Warpeds[corner_coord] = Warped ### read the center: center_pfms_dir = center_res_dir + 'pfms/' print("doing.." + str(center_view)) center_D = read_pfm(glob(center_pfms_dir + '*.pfm')[0]) Warpeds[center_view] = np.expand_dims(center_D, -1) #### fuse: Warped_ims = np.concatenate(list(Warpeds.values()), -1) #fused_Warped = np.median(Warped_ims*(Warped_ims!=inv_pix_val),-1) fused_Warped = np.zeros_like(center_D) for ir in range(D.shape[0]): for ic in range(D.shape[1]): vals = Warped_ims[ir, ic, :] valid_vals = vals[vals != inv_pix_val] fused_Warped[ir, ic] = np.median(valid_vals) ## show end result plt_imshow(center_D) plt_imshow(fused_Warped) if save_output: write_pfm( fused_Warped, output_dir + sample + '_' + str(center_view[0]) + '_' + str(center_view[1]) + '.pfm')