Skip to content

error: (-2:Unspecified error) More than one input is Const op in function 'getConstBlob' #13839

Closed

Description

@taerc
System information (version)
  • OpenCV => 3.4.5
  • Operating System / Platform => Mac OS X
  • Compiler => cv2.error: OpenCV(3.4.5)
Detailed description
  1. I wrote the model of PNet into freeze pb, the load the mode by readNetFromTensorflow. Then it occur error . I tried for RNet and ONet, then load correctly.
  2. Does the dnn do not support load multi-input nodes ? I modify the input of the pb as only one input, error occor as the same.
Steps to reproduce
```.python
    pb_file = "PNet_pnet.pb"

    net = cv.dnn.readNetFromTensorflow(pb_file)
    print(net)
```

cv2.error: OpenCV(3.4.5) /Users/travis/build/skvark/opencv-python/opencv/modules/dnn/src/tensorflow/tf_importer.cpp:522: error: (-2:Unspecified error) More than one input is Const op in function 'getConstBlob'

PNet_pnet.pb

Appreciate for your help.

Activity

  1. dkurt commented on Feb 15, 2019

    @dkurt
    Member

    @plbmw, May I ask you to provide some code with network definition? At least a part with flattening,
    screenshot from 2019-02-15 12-24-19

  2. taerc commented on Feb 16, 2019

    @taerc
    Author

    @dkurt Here is the network definition.

    def P_Net(inputs, label=None, bbox_target=None, landmark_target=None, training=False):
        # define common param
        with slim.arg_scope([slim.conv2d],
                            activation_fn=prelu,
                            weights_initializer=slim.xavier_initializer(),
                            biases_initializer=tf.zeros_initializer(),
                            weights_regularizer=slim.l2_regularizer(0.0005),
                            padding='valid'):
    
            net = slim.conv2d(inputs, num_outputs=10, kernel_size=3, stride=1, scope='conv1')
            net = slim.max_pool2d(net, kernel_size=[2, 2], stride=2, scope='pool1', padding='SAME')
            net = slim.conv2d(net, num_outputs=14, kernel_size=[3, 3], stride=1, scope='conv2')  
            net = slim.conv2d(net, num_outputs=16, kernel_size=[3, 3], stride=1, scope='conv3')
            # batch*H*W*2
            conv4_1 = slim.conv2d(net, num_outputs=2, kernel_size=[1, 1], stride=1, scope='conv4_1',
                                  activation_fn=tf.nn.softmax)
            # batch*H*W*4
            bbox_pred = slim.conv2d(net, num_outputs=4, kernel_size=[1, 1], stride=1, scope='conv4_2', activation_fn=None)
            print(bbox_pred.get_shape())
            # batch*H*W*10
            landmark_pred = slim.conv2d(net, num_outputs=10, kernel_size=[1, 1], stride=1, scope='conv4_3',
                                        activation_fn=None)
            print(landmark_pred.get_shape())
            # cls_prob_original = conv4_1
            # bbox_pred_original = bbox_pred
            # when test,batch_size = 1
            cls_pro_test = tf.squeeze(conv4_1, axis=0, name="cls_prob")
            bbox_pred_test = tf.squeeze(bbox_pred, axis=0, name="bbox_pred")
            landmark_pred_test = tf.squeeze(landmark_pred, axis=0, name="landmark_pred")
            return cls_pro_test, bbox_pred_test, landmark_pred_test
    
  3. taerc commented on Feb 16, 2019

    @taerc
    Author

    @dkurt I remove squeeze ops refer to Layers for MobileNet from TensorFlow #9517 , then dnn load PNet_pnet.pb successfully. Can you provide some tutorials or blogs for the newer ?

    Appreciate for your help very much.

  4. taerc commented on Feb 16, 2019

    @taerc
    Author

    @dkurt The output results varied when I remove the squeeze from the network definition. I check the graph in the tensorboard, the Softmax operation is missing. I substitute the tf.sequeeze by tf.identity, but the DNN can not load the PB. How can I solve this problem ? Maybe other solution can substitute.
    op-diff-with-squeeze

  5. self-assigned this
    on Apr 12, 2019
  6. dkurt commented on Apr 12, 2019

    @dkurt
    Member

    @plbmw, please test the changes from PR #14315 (the model from issue's topic works for me).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions