vcg-uvic / lf-net-release

Code Release for LF-Net: Learning Local Features from Images

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Using lf-net in OpenCV dnn

gpcbitnik opened this issue · comments

Hello,
i try to freeze your model in order to use it with opencv dnn module to test it in my application.
i frozen the model using this lines :

` input_graph_def = sess.graph.as_graph_def()

output_node_names=ops['kpts'].op.name+","+ops['feats'].op.name+","+ops['scale_maps'].op.name+","+ops['kpts_scale'].op.name+","+ops['degree_maps'].op.name+","+ops['kpts_ori'].op.name
output_graph_def = graph_util.convert_variables_to_constants(
        sess, # The session
        input_graph_def, # input_graph_def is useful for retrieving the nodes 
        output_node_names.split(",")  
)


output_graph="export/frozen.pb"
with tf.gfile.GFile(output_graph, "wb") as f:
    f.write(output_graph_def.SerializeToString())
tf.train.write_graph(output_graph_def, 'export/', 'frozentxt.pbtxt',as_text=True)`

and then i use the thoses lines to optimze the networks

`with tf.gfile.FastGFile(output_graph, "rb") as f:
    graph_def = tf.GraphDef()
    graph_def.ParseFromString(f.read())
    tf.summary.FileWriter('logs', graph_def)

    inp_node = 'Placeholder'
    out_node =  output_node_names.split(",")
    graph_def = optimize_for_inference_lib.optimize_for_inference(graph_def, [inp_node], out_node,
                                                                tf.float32.as_datatype_enum)
    graph_def = TransformGraph(graph_def, [inp_node], out_node, ["sort_by_execution_order"])

    tf.train.write_graph(graph_def, "export/", 'graph_opt.pbtxt', as_text=True)`

but i get some warnings

WARNING:tensorflow:Didn't find expected Conv2D input to 'MSDeepDet/ConvOnlyResNet/block-1/pre-bn/FusedBatchNorm'

WARNING:tensorflow:Didn't find expected Conv2D input to 'MSDeepDet/ConvOnlyResNet/block-1/mid-bn/FusedBatchNorm'

WARNING:tensorflow:Didn't find expected Conv2D input to 'MSDeepDet/ConvOnlyResNet/block-2/pre-bn/FusedBatchNorm'

WARNING:tensorflow:Didn't find expected Conv2D input to 'MSDeepDet/ConvOnlyResNet/block-2/mid-bn/FusedBatchNorm'

WARNING:tensorflow:Didn't find expected Conv2D input to 'MSDeepDet/ConvOnlyResNet/block-3/pre-bn/FusedBatchNorm'

WARNING:tensorflow:Didn't find expected Conv2D input to 'MSDeepDet/ConvOnlyResNet/block-3/mid-bn/FusedBatchNorm'

WARNING:tensorflow:Didn't find expected Conv2D input to 'MSDeepDet/ConvOnlyResNet/fin-bn/FusedBatchNorm'

WARNING:tensorflow:Didn't find expected Conv2D input to 'SimpleDesc/bn1/FusedBatchNorm'

WARNING:tensorflow:Didn't find expected Conv2D input to 'SimpleDesc/bn2/FusedBatchNorm'

WARNING:tensorflow:Didn't find expected Conv2D input to 'SimpleDesc/bn3/FusedBatchNorm'

thoses nodes that generate warnings are the nodes with ConvOnlyRestNet as an input.
this bloc have no relation with the placeholder node so how can it get the input blob?

there is something i'm not understanding, could you help me please?
kind regards

Oh, this is so cool. I suspect the main reason would be tensorflow version issue. There's also a docker image available. Have you tried them?

Hi, it seems your image decided to go to the void :-( What I suspect is that these could be remnants of our hasty development, but I am not entirely sure. @xyukiono Can you perhaps try to chime in?

try to add the image again
frozen Graph
frozenGraph
original Graph
originalGraph