[ disp_out.reshape(-1, 1), dataset_img['t_disps'], #t_disps[ntest], dataset_img['gtruths'], # gtruths[ntest], dbg_cost_nw.reshape(-1, 1), dbg_cost_w.reshape(-1, 1), dbg_d.reshape(-1, 1), dbg_avg_disparity.reshape(-1, 1), dbg_gt_disparity.reshape(-1, 1), dbg_offs.reshape(-1, 1) ], 1) np.save(result_file, rslt.reshape(HEIGHT, WIDTH, -1)) rslt = qsf.eval_results(result_file, ABSOLUTE_DISPARITY, radius=CLUSTER_RADIUS, logfile=lf) img_gain_test0 = rslt[0][0] / rslt[0][1] img_gain_test9 = rslt[9][0] / rslt[9][1] if SAVE_TIFFS: qsf.result_npy_to_tiff(result_file, ABSOLUTE_DISPARITY, fix_nan=True, labels=SLICE_LABELS, logfile=lf) """ Remove dataset_img (if it is not [0] to reduce memory footprint """ if ntest > 0: image_data[ntest] = None if lf:
qsf.print_time("Running inferred model, stage2", end=" ") disp_out, = sess.run([stage2_out_sparse], feed_dict={ph_ntile_out: img_ntile }) qsf.print_time("Done.") result_file = files['result'][nimg].replace('.npy','-infer.npy') #not to overwrite training result files that are more complete try: os.makedirs(os.path.dirname(result_file)) except: pass rslt = np.concatenate( [disp_out.reshape(-1,1), dataset_img['t_disps'], #t_disps[ntest], dataset_img['gtruths'], # gtruths[ntest], ],1) np.save(result_file, rslt.reshape(HEIGHT,WIDTH,-1)) rslt = qsf.eval_results(result_file, ABSOLUTE_DISPARITY, radius=CLUSTER_RADIUS, logfile=lf) # (re-loads results). Only uses first 4 layers if SAVE_TIFFS: qsf.result_npy_to_tiff(result_file, ABSOLUTE_DISPARITY, fix_nan = True,labels=SLICE_LABELS, logfile=lf) """ Remove dataset_img (if it is not [0] to reduce memory footprint """ image_data[nimg] = None """ Save MetaGraph to Saved_Model in *.pb (protocol buffer) format to be able to use from Java """ # force clean shutil.rmtree(dirs['exportdir'], ignore_errors=True) builder = tf.saved_model.builder.SavedModelBuilder(dirs['exportdir']) builder.add_meta_graph_and_variables(sess,[tf.saved_model.tag_constants.SERVING],main_op=tf.local_variables_initializer())