Giter Site home page Giter Site logo

aliushn / maskrcnn_tensorflow_cpp_inference Goto Github PK

View Code? Open in Web Editor NEW

This project forked from casontsai/maskrcnn_tensorflow_cpp_inference

0.0 1.0 0.0 1.42 MB

inference mask_rcnn model with tensorflow c++ api

License: MIT License

C++ 100.00%

maskrcnn_tensorflow_cpp_inference's Introduction

MaskRcnn_tensorflow_cpp_inference

inference mask_rcnn model with tensorflow c++ api

Because of the work, the segmentation will catch up later

this project consists of three main operations

  1. keras model to tensorflow model: because we use front-end keras call the backend tensorflow,so we need to convert keras model to tensorflow model.
  2. inference tensorflow model with cpp,and use Eigen3 lib carefully.
  3. note that such as batch_size,the operation that save model in gpu or cpu ,must be same as the config you set in the python call.

enviroment:

tensorflow c++ library:(https://github.com/fo40225/tensorflow-windows-wheel) this project's tf version 1.8.0 avx2 gpu.
cuda(if use gpu): cuda 9.1
protobuf(if use gpu)๏ผš protobuf 3.6
opencv: 3.3.0
system : win10
gui tool :qt 5.8.0
compile tool : msvc2015

tutorials:

keras model to tensorflow model

> download the front-end keras  mask_rcnn model and install it  https://github.com/matterport/Mask_RCNN  
> download this https://github.com/parai/Mask_RCNN for converting keras model to tensorflow model 
> 1.modify matterport's Mask_RCNN/samples/coco/coco.py

Image

> 2.modify inference config ,especially parameter GPU_COUNT and IMAGES_PER_GPU,these two parameter must be same as that of parai's Mask_RCNN-master/samples/demo.py ,otherwise will get error. parameter  IMAGES_PER_GPU   involve the image nums when we use batch inference 
,mine is 32 , 1080 ti could handle  32 images with  size is  512*512.  

Image

> 3.modify the  class nums ,and IMAGE_MIN_DIM ,IMAGE_MAX_DIM in class CcocoConfig,int this project IMAGE_MIN_DIM = 512,IMAGE_MAX_DIM = 512,class nums is 1+6,these parameter according to yours

Image

> 4.  run the coco.py ,we can get the keras model(model+weight),this project's keras model name is mask_rcnn_whole_batch32_new20.h5  
> 5.  begin convert keras model to tensorflow model, the following operations are mainly make some config in `parai's Mask_RCNN-master/samples/demo.py` be same as  `matterport's Mask_RCNN/samples/coco/coco.py` 
>>  5.1 modify parameter NUM_CLASSES and IMAGE_MIN_DIM  IMAGE_MAX_DIM of  CocoConfig in  `parai's Mask_RCNN-master/samples/demo.py` 

Image
Image

>>  5.2 modify inferenceConfig in  `parai's Mask_RCNN-master/samples/demo.py`  

Image
Image

>>  5.3 modify `parai's Mask_RCNN-master/scripts/export_model.py` 

Image

>>  5.4 run `parai's Mask_RCNN-master/samples/demo.py` we will get the mask_rcnn tensorflow model finally,tf model file name in this project's is mask_rcnn_batch32_new20.pb ,in this step ,we finish conveter the keras model into tensorflow model,we  could  use `parai's Mask_RCNN-master/infere_from_pb.py` to test the pb file to check  whether result is correcet or not

c++ inference tensorflow model

> 1.  all we need cpp file are `data_format.h,detectbatch.cpp ,detectbatch.h`   
> 2.  the main.cpp is show how to use `data_format.h,detectbatch.cpp ,detectbatch.h` to detect the image 

Image

If you have any good Suggestions, please give them to me. I would really appreciate it

SSD deployment with c/c++ is currently under way

maskrcnn_tensorflow_cpp_inference's People

Contributors

casontsai avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.