Open shubham9436 opened 5 years ago
I have frozen the city2kitti model and I want to use in multprocessing. Can anyone help me in that? Below is the code snippet :
frozen_graph = "graph_optimized.pb"
with tf.gfile.GFile(frozen_graph, "rb") as f: graph_def = tf.GraphDef() graph_def.ParseFromString(f.read())
with tf.Graph().as_default() as graph: tf.import_graph_def(graph_def, input_map=None, return_elements=None, name="")
y_pred = graph.get_tensor_by_name("model/output_depth:0") x = graph.get_tensor_by_name("input_image:0")
sess = tf.Session(graph=graph)
while (cap.isOpened): ret, input_image = cap.read() if input_image is None: break start = time.time() input_image = cv2.resize(input_image, (512, 256)) orig = input_image input_image = input_image.astype(np.float32) / 255 input_images = np.stack((input_image, np.fliplr(input_image)), 0) disp = sess.run(y_pred, feed_dict={x: input_images}) disp_pp = post_process_disparity(disp.squeeze()).astype(np.float32) disp_to_img = scipy.misc.imresize(disp_pp.squeeze(), [256, 512]) disp_to_img = cv2.applyColorMap(disp_to_img, cv2.COLORMAP_SPRING) cv2.imshow('processed', disp_to_img) cv2.imshow('unprocessed', orig) if cv2.waitKey(1) & 0xFF == ord('q'): break
Thanks
I have frozen the city2kitti model and I want to use in multprocessing. Can anyone help me in that? Below is the code snippet :
frozen_graph = "graph_optimized.pb"
with tf.gfile.GFile(frozen_graph, "rb") as f: graph_def = tf.GraphDef() graph_def.ParseFromString(f.read())
with tf.Graph().as_default() as graph: tf.import_graph_def(graph_def, input_map=None, return_elements=None, name="")
y_pred = graph.get_tensor_by_name("model/output_depth:0") x = graph.get_tensor_by_name("input_image:0")
sess = tf.Session(graph=graph)
while (cap.isOpened): ret, input_image = cap.read() if input_image is None: break start = time.time() input_image = cv2.resize(input_image, (512, 256)) orig = input_image input_image = input_image.astype(np.float32) / 255 input_images = np.stack((input_image, np.fliplr(input_image)), 0) disp = sess.run(y_pred, feed_dict={x: input_images}) disp_pp = post_process_disparity(disp.squeeze()).astype(np.float32) disp_to_img = scipy.misc.imresize(disp_pp.squeeze(), [256, 512]) disp_to_img = cv2.applyColorMap(disp_to_img, cv2.COLORMAP_SPRING) cv2.imshow('processed', disp_to_img) cv2.imshow('unprocessed', orig) if cv2.waitKey(1) & 0xFF == ord('q'): break
Thanks