Closed kikirizki closed 6 years ago
Hi, thanks for the question. I'm not sure why this code is much slower than your python code (since I can't see the python code), but I highly doubt that tensorflow itself is slower in C++. If you want to compare the tensorflow C++ API performance to the python API performance, I'd suggest remove everything from your update loop that isn't directly related to tensorflow. I.e. get rid of the video capture and scoring, and only leave the session->run. Then gradually introduce other elements.
By the way, apologies if this is a silly question, but you do know that cv::waitKey(33) means 'sleep for 33 milliseconds' right? And you do the same in python?
I am sorry my bad. I didn't aware that I write waitKey(33), I just copy and paste from my old webcam program, oh silly me. Now it is work and a little faster than the python counterpart. I think the problem is solved, thank you
Ok great to hear that :)
hello @kikirizki @memo , could you please explain to me how can I run the above code to my Linux machine? i have already built Tensorflow by using bazal builder. but I do not know what is the following steps to compile and run your prediction code using SSD MODEL. I will really appreciate your advice. and thanks in advance
hello @kerolos ... sorry for late reply, just try to clone my repo https://github.com/memo/ofxMSATensorFlow/issues/34#issuecomment-366619818
I have compile it my self and there is a script in the repo to run it, hope its help
i mean here is the repo https://github.com/kikirizki/tensorflow-nobazel
thanks a lot @kikirizki for your reply and help :) .
@kikirizki @memo hi guys i am also facing the same issue my python code takes a time of 4 sec and my c ++ code takes 18 secs , i have frozen.pb model which i use to create the binary can you give me some suggestions on it
Recently I try to run ssd with mobilenet model from tensorflow object detection api. I try to run realtime object detection using tensorflow+opencv on both python and c++, surprisingly the c++ is much slower than the python API. I am sure that I run both of them with GPU support, here is my code
Note : Since I do not know how to convert cv::Mat into tensor, I do not actually detect the object from the camera for each frame instead I substitute the cv::Mat with image from image file ("cat.jpg"). My intention is to compare the performance between tensorflow C++ and python API for object detection w mobilenet.. thanks,
oke then why the C++ API is slower? thanks