Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Problem loading MobilenetV1 (from Keras) with OpenCV::DNN

I have a trained mobilenetv1 network and I get the following error when I try to read the model with cv2.dnn.readNetFromTensorflow():

OpenCV(3.4.1) /feedstock_root/build_artefacts/opencv_1520722599420/work/opencv-3.4.1/modules/dnn/src/tensorflow/tf_importer.cpp:1582: error: (-2) Unknown layer type Minimum in op mobilenet_0_25_48/conv1_relu/Minimum in function populateNet

I followed all the steps for converting the Keras model to Tensorflow model (https://github.com/opencv/opencv/pull/9517).

Here one of the problematic part (*.pbtxt):

node {
  name: "input_1"
  op: "Placeholder"
  attr {
    key: "dtype"
    value {
      type: DT_FLOAT
    }
  }
  attr {
    key: "shape"
    value {
      shape {
        dim {
          size: -1
        }
        dim {
          size: 48
        }
        dim {
          size: 48
        }
        dim {
          size: 1
        }
      }
    }
  }
}
node {
  name: "mobilenet_0_25_48/conv1_pad/Pad"
  op: "Pad"
  input: "input_1:0"
  input: "mobilenet_0_25_48/conv1_pad/Pad/paddings"
}
node {
  name: "mobilenet_0_25_48/conv1/convolution"
  op: "Conv2D"
  input: "mobilenet_0_25_48/conv1_pad/Pad"
  input: "conv1/kernel/read/_0__cf__0"
  attr {
    key: "dilations"
    value {
      list {
        i: 1
        i: 1
        i: 1
        i: 1
      }
    }
  }
  attr {
    key: "padding"
    value {
      s: "VALID"
    }
  }
  attr {
    key: "strides"
    value {
      list {
        i: 1
        i: 2
        i: 2
        i: 1
      }
    }
  }
}
node {
  name: "mobilenet_0_25_48/conv1_bn/batchnorm/mul_1"
  op: "Mul"
  input: "mobilenet_0_25_48/conv1/convolution"
  input: "mobilenet_0_25_48/conv1_bn/batchnorm/mul/_27__cf__27"
}
node {
  name: "mobilenet_0_25_48/conv1_bn/batchnorm/add_1"
  op: "Add"
  input: "mobilenet_0_25_48/conv1_bn/batchnorm/mul_1"
  input: "mobilenet_0_25_48/conv1_bn/batchnorm/sub/_28__cf__28"
}
node {
  name: "mobilenet_0_25_48/conv1_relu/Relu"
  op: "Relu"
  input: "mobilenet_0_25_48/conv1_bn/batchnorm/add_1"
}
node {
  name: "mobilenet_0_25_48/conv1_relu/Minimum"
  op: "Minimum"
  input: "mobilenet_0_25_48/conv1_relu/Relu"
  input: "mobilenet_0_25_48/conv1_relu/Const"
}
node {
  name: "mobilenet_0_25_48/conv_pad_1/Pad"
  op: "Pad"
  input: "mobilenet_0_25_48/conv1_relu/Minimum"
  input: "mobilenet_0_25_48/conv_pad_1/Pad/paddings"
}
node {
  name: "mobilenet_0_25_48/conv_dw_1/depthwise"
  op: "DepthwiseConv2dNative"
  input: "mobilenet_0_25_48/conv_pad_1/Pad"
  input: "conv_dw_1/depthwise_kernel/read/_1__cf__1"
  attr {
    key: "dilations"
    value {
      list {
        i: 1
        i: 1
        i: 1
        i: 1
      }
    }
  }
  attr {
    key: "padding"
    value {
      s: "VALID"
    }
  }
  attr {
    key: "strides"
    value {
      list {
        i: 1
        i: 1
        i: 1
        i: 1
      }
    }
  }
}