Git Product home page Git Product logo

semantic_human_matting-pytorch_openvino's Introduction

 0. None

The project refers to https://github.com/lizhengwei1992/Semantic_Human_Matting.

Finally, I converted the pytorch model to the openvino model, and run it on cpu.

 1. My Environment: 

 for python:

python == 3.6.5

pytorch-gpu == 1.2.0

torchvision == 0.4.0

cv2 == 4.1.2

 for C++:

openvino == 2019.3.334

opencv == 4.1.2

 2. Prepare train dataset

Download alpha images from: https://pan.baidu.com/s/1geFwrv7H3moFc9nxXwQJ1g (boy2)

Download init images and mask images from: https://pan.baidu.com/s/1R9PJJRT-KjSxh-2-3wCGxQ (dzsn)

Unzip alpha to data folder and execute:

(1) cd data

(2) use alpha images to generate trimap images: python gen_trimap.py

(3) generate train.txt: python gen_train_data_list.py

 3. Train

I set patch_size = 256, train_batch = 32.

(1) train phase 1:

python train.py --finetuning False --lr 1e-3 --nEpochs 100 --train_phase pre_train_t_net

(2) train phase 2:

python train.py --finetuning True --lr 1e-4 --nEpochs 200 --train_phase end_to_end

 4. Test

Put images into images folder and run python test_image.py.

 5. OpenVINO

(1) Convert model_obj.pth to model_obj.onnx: python torch_to_onnx.py

(2) Copy model_obj.onnx to C:\IntelSWTools\openvino_2019.3.334\deployment_tools\model_optimizer, and run:

python mo_onnx.py --input_shape=[1,3,256,256] --mean_values [104.0,112.0,121.0] --scale_values [255.0,255.0,255.0] --input_model .\model_obj.onnx -o .\

Alter that, we have two files: model_obj.xml(model information file) and model_obj.bin(weights file).

 6. Qt

Build Kit: Desktop Qt 5.12.0 MSVC2015 64bit, Release.

OpenVINO model files: openvino_model/model_obj.xml, openvino_model/model_obj.bin.

(1) Create a new qt console project.

(2) Copy the content of file 'for_qt/console_test.pro' to your own .pro file.

(3) Use file 'for_qt/main.cpp' in your project.

semantic_human_matting-pytorch_openvino's People

Contributors

bithg287 avatar

Watchers

James Cloos 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.