Search code examples
pythonopencvclassificationvideo-captureh5py

How to load a keras model file to OpenCV code?


I've created a traffic sign classification model. I need to use it in OpenCV for Video traffic sign detection. How can I do that using a .h5 file

Thanks in advance!


Solution

  • In openCV you can read weights with

    cv2.dnn.readNetFromCaffe
    cv2.dnn.readNetFromTensorFlow
    cv2.dnn.readNetFromTorch
    cv2.dnn.readhTorchBlob
    

    Because you can not read with opencv without manipulations and you need:

    1. You can read frames with OpenCV and put the frames to run in Keras
    2. Or you can convert keras model to tensorflow model and run with Opencv cv2.dnn.readNetFromTensorFlow