Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using lf-net in OpenCV dnn #17

Open
gpcbitnik opened this issue Dec 4, 2019 · 4 comments
Open

Using lf-net in OpenCV dnn #17

gpcbitnik opened this issue Dec 4, 2019 · 4 comments

Comments

@gpcbitnik
Copy link

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

@kmyi
Copy link
Member

kmyi commented Dec 4, 2019

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?

@gpcbitnik
Copy link
Author

gpcbitnik commented Dec 4, 2019 via email

@kmyi
Copy link
Member

kmyi commented Dec 4, 2019

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?

@gpcbitnik
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants