I trained my own model using the faster_rcnn_resnet50_coco.config. After training, I saved the model using export_inference_graph.py. The frozen_inference_graph.pb, labelmap.pbtxt, graph.pbtxt are here.
Could you please tell me what I am doing wrong here.
import numpy as np
import cv2
# read and convert the image to the format that similar to mnist image
x_image = cv2.imread('test.png')
x_image = cv2.resize(x_image, dsize=(320,180))
x_image = 255 - x_image x_image = x_image / 255. x_image = x_image.astype(np.float32)
# read model and inference inputBlob = cv2.dnn.blobFromImage(x_image)
net = cv2.dnn.readNetFromTensorflow('inference_graph/frozen_inference_graph.pb')
net.setInput(inputBlob) result = net.forward()
print(result) print(np.argmax(result, 1))
Error message
ToFloat:Cast(Const)
DstT:[ ]
SrcT:[ ]
OpenCV Error: Unspecified error (Unknown layer type Cast in op ToFloat) in cv::dnn::experimental_dnn_v3::`anonymous-namespace'::TFImporter::populateNet, file C:\projects\opencv-python\opencv\modules\dnn\src\tensorflow\tf_importer.cpp, line 1487
---------------------------------------------------------------------------
error Traceback (most recent call last)
C:\tensorflow1\models\research\object_detection\opencvtesting.py in <module>()
12 inputBlob = cv2.dnn.blobFromImage(x_image)
13
---> 14 net = cv2.dnn.readNetFromTensorflow('inference_graph/frozen_inference_graph.pb')
15 net.setInput(inputBlob)
16 result = net.forward()
error: C:\projects\opencv-python\opencv\modules\dnn\src\tensorflow\tf_importer.cpp:1487: error: (-2) Unknown layer type Cast in op ToFloat in function cv::dnn::experimental_dnn_v3::`anonymous-namespace'::TFImporter::populateNet