MCPcopy Index your code
hub / github.com/tensorpack/tensorpack / apply_compact

Function apply_compact

examples/basics/export-model.py:155–168  ·  view source on GitHub ↗

Run the pruned and frozen inference graph.

(graph_path)

Source from the content-addressed store, hash-verified

153
154
155def apply_compact(graph_path):
156 """Run the pruned and frozen inference graph. """
157 with tf.Session(config=tf.ConfigProto(allow_soft_placement=True)) as sess:
158 # Note, we just load the graph and do *not* need to initialize anything.
159 with tf.gfile.GFile(graph_path, "rb") as f:
160 graph_def = tf.GraphDef()
161 graph_def.ParseFromString(f.read())
162 tf.import_graph_def(graph_def)
163
164 input_img = sess.graph.get_tensor_by_name('import/input_img:0')
165 prediction_img = sess.graph.get_tensor_by_name('import/prediction_img:0')
166
167 prediction = sess.run(prediction_img, {input_img: cv2.imread('lena.png')[None, ...]})
168 cv2.imwrite('applied_compact.png', prediction[0])
169
170
171if __name__ == '__main__':

Callers 1

export-model.pyFile · 0.85

Calls 2

readMethod · 0.80
runMethod · 0.45

Tested by

no test coverage detected