1
$\begingroup$

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!

$\endgroup$
2
$\begingroup$
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)))
$\endgroup$
2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.