OpenCVForUnity
OpenCVForUnity copied to clipboard
DNN module crash when using a custom TensorFlow model
Hello, I'm trying to integrate my custom TensorFlow model to OpenCVForUnity DNN modules but the Unity editor crash. I have already trained my model using Keras and convert the model to .pb. However, the unity editor crash when I copy protobuf file and create a tag.txt in Assets/StreamingAssets/dnn. If the problem can be solved, could you please elaborate the solution for me.
I'm going to give the model file because it might be helpful. tensorflow_inception_graph.zip
thank you very much
Thank you for your inquiry.
Unfortunately, I don't know much about the Deep learning and Tensorflow models. In order to read the pb file with OpenCV, it seems that it is necessary to convert it for OpenCV. https://stackoverflow.com/questions/60625128/importing-automl-edge-train-model-in-opencv https://github.com/opencv/opencv/wiki/TensorFlow-text-graphs https://github.com/opencv/opencv/wiki/TensorFlow-Object-Detection-API
Thank you for your response, It's seems like we need to freeze the model into a single inference graph before passing it to OpenCV DNN otherwise the Unity Editor will crash. This might be a problem in OpenCV itself.
Freezing Graph in TensorFlow 2.0 is quite difficult so I'm going to place the solution here in case someone have same problem https://github.com/leimao/Frozen_Graph_TensorFlow