How to generate a configuration file for tensorflow openpose model ?

asked 2018-03-19 12:30:03 -0500

Roma gravatar image

updated 2018-03-20 08:26:16 -0500

In opencv for detection models to generate a config file is used:

What I have to change in "tf_text_graph_ssd" or what to use to generate a config file for opencv using the tensorflow openpose model ?

I have the inference openpose model:

This is the result of the model using Tensorflow with OpenPose: C:\fakepath\openpose.png

But OpenCV needs a config file. So I don't know how to generate what file for OpenCV

edit retag flag offensive close merge delete


do you want to retrain the openpose model ? or just use the existing COCO or MPI model ?

in the latter case, please try with the sample

also, here are the data url's to download

berak gravatar imageberak ( 2018-03-19 12:33:13 -0500 )edit

I tried that script( using caffe models and it is working nicely, but now I want to try it with above tensorflow model but I dont know how to generate the config file for opencv. thank you for your help.

Roma gravatar imageRoma ( 2018-03-19 12:43:29 -0500 )edit

@Roma, a text config file is optional. Please tell us what kind of errors appear during import of a single .pb model.

dkurt gravatar imagedkurt ( 2018-03-19 22:28:10 -0500 )edit

i tried the tf model (w/o a prototxt, from c++), it has the same layershapes at the top, as the original openpose model ([1, 57, 46, 46]) .

no errors, but the confidence is low(<0.01), and the positions are somewhat off.

berak gravatar imageberak ( 2018-03-20 03:54:04 -0500 )edit

@berak when using tensorflow it outputs reasonable results, look the above image.

Roma gravatar imageRoma ( 2018-03-20 07:21:24 -0500 )edit

^^ ohh, nice. but that's using openpose code, not opencv , right ?

(it would be really cool, to get this running in opencv, it's 10x faster !)

can you put the code somewhere ? (curious, what i might be doing wrong here !)

berak gravatar imageberak ( 2018-03-20 07:31:37 -0500 )edit

tada, solved it !!!!

image description

(all it needed, was to skip the 1/255 normalization factor in blobFromImage())

@dkurt, 10x faster ! only 7mb ! we NEED that !

berak gravatar imageberak ( 2018-03-20 07:46:07 -0500 )edit

@berak yes that is using openpose code ^^

@berak very nice ! ^^ your using the above model with c++ and opencv and that is working ?

Roma gravatar imageRoma ( 2018-03-20 08:18:54 -0500 )edit

@berak, Wow, that's amazing! We can replace readNetFromCaffe to readNet in both Python and C++ samples. It's independent to binary/text files order and can detect an origin framework automatically. I think it's ok if we make mean as sample's argument and add a new table Othersto including two rows with each model.

dkurt gravatar imagedkurt ( 2018-03-20 08:22:27 -0500 )edit

@Roma, yes opencv/c++. i changed the importer (from caffe to tf) and replaced 1/255 with 1 in blobFromImage() (and nparts==19 || nparts==57here.

similar idea should work with the python code, too.

so, while it does not need a prototxt now, it might still be good, to have one, imho, maybe one could do some further optimization there

berak gravatar imageberak ( 2018-03-20 08:24:05 -0500 )edit