serizba / cppflow

Run TensorFlow models in C++ without installation and without Bazel
https://serizba.github.io/cppflow/
MIT License
788 stars 178 forks source link

how to run an image segmentation model #140

Closed abucka closed 2 years ago

abucka commented 3 years ago

How can I run an image segmentation model (Mask-RCNN, matterport implementation) in cppflow?

bozdemir commented 2 years ago

I am also interested in this matter, any response will be greatly appreciated.

dskkato commented 2 years ago

Perhaps, you can run inference part of semantic segmentation model described in the following example.

https://github.com/serizba/cppflow/blob/master/examples/efficientnet/main.cpp

The difficult part is how to how to handle it's output. Since output is a tensor of the cppflow, you can easily obtain its shape using some method.

     ​auto​ shape_tensor = t1.​shape​(); 
 ​    ​auto​ shape = shape_tensor.​get_data​<​int64_t​>()[​0​];

See this example https://github.com/serizba/cppflow/blob/master/examples/tensor/main.cpp

Then, final part is how to iterate over the tensor to get the inference result. See following example code.

https://github.com/serizba/cppflow/blob/master/examples/load_model/main.cpp#L17-L19

serizba commented 2 years ago

Thanks for the explanation @dskkato