Ask Your Question
1

How to use LayerParam to get a dictionary of scalar params of a layer in OpenCV DNN module?

asked 2018-06-05 02:00:57 -0500

sm_asimo gravatar image

Hi, I am facing problem to retrieve scalar params corresponding to a layer after importing a trained model from a frozen graph(.pb). The documentation mentions a class "Dict" that manages this, but no example has been provided to work it out.

edit retag flag offensive close merge delete

Comments

1

To get weights I use :

Ptr<dnn::Layer> l = net.getLayer("conv1");
vector<Mat> bb = l->blobs;
LBerger gravatar imageLBerger ( 2018-06-05 02:15:41 -0500 )edit

@LBerger, e.g. conv layers have attributes, like stride and padding. and those are not accessible from c++

berak gravatar imageberak ( 2018-06-05 02:19:43 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2018-06-05 02:09:42 -0500

berak gravatar image

updated 2018-06-05 02:14:01 -0500

sadly, as of now, it's not possible (they are not exposed to the public api).

you can traverse the layers, get their names, shapes, input connections, blobs, but that's about it, the LayerParams are hidden in the (private) DnnImpl class.

you could try to generate a (human readable) pbtxt file from the tensorflow api, which has all that information .

edit flag offensive delete link more

Comments

1

Thanks for your input. I am already using the human readable format (.pbtxt) for this information. Just wanted to know if in-build method was available. After trying out different hacks myself and the information provided by you, I guess I will have to settle with .pbtxt method.

sm_asimo gravatar imagesm_asimo ( 2018-06-05 02:13:49 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2018-06-05 02:00:57 -0500

Seen: 48 times

Last updated: Jun 05 '18