Ask Your Question

what is the change of dnn module in opencv4.1?

asked 2019-04-17 00:34:31 -0600

lunasdejavu gravatar image

updated 2019-04-19 00:53:38 -0600

dkurt gravatar image

the changlog of opencv 4.1 : New networks from TensorFlow Object Detection API: Faster-RCNNs, SSDs and Mask-RCNN with dilated convolutions, FPN SSD but I remember opencv 4.0.0 can use these models since I have tried faster-RCNNs and Mask-RCNN so what is the difference?

The second question is that is any other way to read the model is not from tensorflow-object detection api now? like this custom MaskRCNN?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2019-04-17 01:29:42 -0600

dkurt gravatar image

updated 2019-04-17 01:30:13 -0600

with dilated convolutions

So the models are


and other models with atrous prefix.

The second question is that is any other way to read the model is not from tensorflow-object detection api now? like this custom MaskRCNN(

Only Mask R-CNN from TensorFlow Object Detection API is supported for now (according But we're welcome for contribution if you can find a way to properly import this model (perhaps using the same text graphs representation approach).

edit flag offensive delete link more


thanks a lot! May ask you how cv:dnn to read the model from text graphs? I know how to use it but I don't know where can I find the whole source code.

lunasdejavu gravatar imagelunasdejavu ( 2019-04-17 05:13:08 -0600 )edit

@lunasdejavu, It's a text version of binary .pb files. They are serialized with protobuf. I think you can use existing .pbtxt files for reference.

dkurt gravatar imagedkurt ( 2019-04-17 06:27:40 -0600 )edit

I know I have used it several times. Since I need to read the custom model, I have to write the readNetfromTensorflow() on my own, can you tell me how to do it?

lunasdejavu gravatar imagelunasdejavu ( 2019-04-18 20:22:40 -0600 )edit

@lunasdejavu, feel free to open a feature request at It might be a complicated task due TensorFlow represents graphs using low-level nodes such Add, Mul etc. And it's required to apply some graph transformations depends on it's type (for now we can process SSDs, Faster R-CNNs and Mask R-CNNs from TF OD API but there are different scripts for each of them).

dkurt gravatar imagedkurt ( 2019-04-19 01:00:15 -0600 )edit

@dkurt what if I use pytorch instead of tensorflow? I thought readNetfromTorch only need the model file so that I can just use any customized model I want?

lunasdejavu gravatar imagelunasdejavu ( 2019-05-07 20:48:05 -0600 )edit

PyTorch model should be converted to ONNX. Use cv::dnn::readNet or readNetFromONNX

dkurt gravatar imagedkurt ( 2019-05-07 23:15:11 -0600 )edit

@dkurt then what is cv.dnn.readNetFromTorch for? what kind of models can be read by it?

lunasdejavu gravatar imagelunasdejavu ( 2019-05-08 00:09:03 -0600 )edit

Please use a documentation:

dkurt gravatar imagedkurt ( 2019-05-08 23:01:04 -0600 )edit

Question Tools

1 follower


Asked: 2019-04-17 00:34:31 -0600

Seen: 823 times

Last updated: Apr 19 '19