Open lunasdejavu opened 5 years ago
Hi,
You could use Boost.Python libraries, as I have done. These libraries enable you to do call python methods from C++.
But, you must have a Python Runtime running in the C++ exe, afterward you could load python files with methods inside (obviously jeje) and call them. Also, you are able to pass through boost::python::objects between C++<->Python.
There is a lot of info about it on the Internet if you search a little bit.
Regards,
@oriolorra thanks a lot! I am trying to figure out how to do that now. But since this project needs keras_model() and python is a dynamic language, how do we link tensorflow and keras and compile it after all? I am not quite sure about what Python Runtime is for.
I found the opencv forum administor told me that their api can't work on this project. I think I might try the tensorflow C++ version first.
I found this project is really helpful https://github.com/Neargye/hello_tf_c_api easy to establish the environment to load the model by tensorflow c++ api.
yes,i did
how can I genetate a pbtxtx file to inference in the opencv
hello,have you sloved this problem?can you tell me how to translate the model to .pb?
this is my code implementation https://github.com/CasonTsai/MaskRcnn_tensorflow_cpp_inference
@CasonTsai Hello, have you try to use the .pb and .pbtxt to detect in Opencv4(C++)?
@CasonTsai Hello, have you try to use the .pb and .pbtxt to detect in Opencv4(C++)?
sorry,i don't inference it by c++ with Opencv4. I just transformed the keras to tensorflow model and then used tensorflow c++ api to inferenced it
@CasonTsai Hello, have you try to use the .pb and .pbtxt to detect in Opencv4(C++)?
sorry,i don't inference it by c++ with Opencv4. I just transformed the keras to tensorflow model and then used tensorflow c++ api to inferenced it
Ok, thx a lot!
Since I have trained the model and validate it many times, now I need to read the model and detect the object in images I want in C++.
First, I found that it could read Mask_RCNN model by opencv, but it needed weights in pb and model in pbtxt, so I write something like
then I turned the pb file to pbtxt
then there was an error like [libprotobuf ERROR C:\build\3_4_winpack-build-win64-vc14\opencv\3rdparty\protobu f\src\google\protobuf\text_format.cc:288] Error parsing text-format opencv_tenso rflow.GraphDef: 41208:5: Unknown enumeration value of "DT_RESOURCE" for field "t ype". OpenCV(3.4.4) Error: Unspecified error (FAILED: ReadProtoFromTextFile(param_file , param). Failed to parse GraphDef file: D:/model_1.pbtxt) in cv::dnn::ReadTFNet ParamsFromTextFileOrDie, file C:\build\3_4_winpack-build-win64-vc14\opencv\modul es\dnn\src\tensorflow\tf_io.cpp, line 54
then I found the models are probably different, so is there anyone can give me some guides to do inference mode in C++?