I would like to know how can I extract the feature map of a mobilenet trained on tensorflow object detection API. I want to take that feature map in order to feed another classifier. Thanks!
1 Answer
$\begingroup$
$\endgroup$
2
import tensorflow as tf
# Sample frozen model
MODEL = "frozen_inference_graph.pb"
# An existing operation from the frozen model
OP_NAME = "WeightSharedConvolutionalBoxPredictor/BoxPredictionTower/conv2d_2/BatchNorm/feature_0/beta/read/_360__cf__363"
# Load the graph from the frozen model
detection_graph = tf.Graph()
with detection_graph.as_default():
od_graph_def = tf.GraphDef()
with tf.gfile.GFile(MODEL, 'rb') as fid:
serialized_graph = fid.read()
od_graph_def.ParseFromString(serialized_graph)
tf.import_graph_def(od_graph_def, name='')
# print all operations
for op in detection_graph.get_operations():
print(op.name)
# print tensor ( without :0 you will get the operation itself )
print(detection_graph.get_tensor_by_name("{}:0".format(OP_NAME)))
-
$\begingroup$ Nice :) ! Can you please let me how do you know op name $\endgroup$– MohitCommented Feb 1, 2021 at 7:20
-
$\begingroup$ datascience.stackexchange.com/questions/94071/… Hi, could you take a look here? $\endgroup$– x89Commented May 6, 2021 at 22:19