Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

keras to tensorflow to opencv dnn

##### System information (version)

  • OpenCV => :grey_question:
  • Operating System / Platform => :grey_question:
  • Compiler => :grey_question:
Detailed description

I have a lenet keras model that was trained for car color recognition. I converted it to tensorflow pb file using keras_to_tensorflow from https://github.com/amir-abdi/keras_to_tensorflow I created pbtxt with the keras_to_tensorflow. I tried loading it (cvInference.py) cvNet = cv.dnn.readNetFromTensorflow('d:\tfs\LPR\IP\MAIN\SRC\PythonProjects\Keras\lenetcarColor.pb', 'd:\tfs\LPR\IP\MAIN\SRC\PythonProjects\Keras\lenetcarColor.pbtxt') I got the error: cv2.error: OpenCV(3.4.3) C:\projects\opencv-python\opencv\modules\dnn\src\tensorflow\tf_importer.cpp:614: error: (-215:Assertion failed) const_layers.insert(std::make_pair(name, li)).second in function 'cv::dnn::experimental_dnn_34_v7::`anonymous-namespace'::addConstNodes'

Steps to reproduce

All my files are at https://www.dropbox.com/sh/yi4b529v01p1lz0/AAAtMZO8DfPfSuDPdwGe5dkPa?dl=0 including the train images in a zip file

click to hide/show revision 2
None

updated 2019-01-06 05:57:59 -0600

berak gravatar image

keras to tensorflow to opencv dnn

#####

System information (version)

(version)
  • OpenCV => :grey_question:
  • Operating System / Platform => :grey_question:
  • Compiler => :grey_question:
Detailed description

I have a lenet keras model that was trained for car color recognition. I converted it to tensorflow pb file using keras_to_tensorflow from https://github.com/amir-abdi/keras_to_tensorflow I created pbtxt with the keras_to_tensorflow. I tried loading it (cvInference.py) (cvInference.py)

cvNet = cv.dnn.readNetFromTensorflow('d:\tfs\LPR\IP\MAIN\SRC\PythonProjects\Keras\lenetcarColor.pb',
cv.dnn.readNetFromTensorflow('d:\\tfs\\LPR\\IP\\MAIN\\SRC\\PythonProjects\\Keras\\lenetcarColor.pb',
 'd:\tfs\LPR\IP\MAIN\SRC\PythonProjects\Keras\lenetcarColor.pbtxt')
'd:\\tfs\\LPR\\IP\\MAIN\\SRC\\PythonProjects\\Keras\\lenetcarColor.pbtxt')

I got the error: error:

cv2.error: OpenCV(3.4.3) C:\projects\opencv-python\opencv\modules\dnn\src\tensorflow\tf_importer.cpp:614: error: (-215:Assertion failed) const_layers.insert(std::make_pair(name, li)).second in function 'cv::dnn::experimental_dnn_34_v7::`anonymous-namespace'::addConstNodes'

'cv::dnn::experimental_dnn_34_v7::`anonymous-namespace'::addConstNodes'
Steps to reproduce

All my files are at https://www.dropbox.com/sh/yi4b529v01p1lz0/AAAtMZO8DfPfSuDPdwGe5dkPa?dl=0 including the train images in a zip file