- Notifications
You must be signed in to change notification settings - Fork7
Describes how to run DBFace, a real-time, single-shot face detection model on Intel OpenVINO
License
yas-sim/dbface-on-openvino
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
The objective of this project is to run the DBFace, a real-time, single-stage face detector on Intel(r) Distribution of OpenVINO(tm) Toolkit.
Original DBFace GitHub site:https://github.com/dlunion/DBFace
Thie original developer used PyTorch to train the model. You need to convert the PyTorch model to OpenVINO IR model. You need to run 2 conversion steps to get the final IR model.
PyTorch (.pth) -> ONNX (.onnx) -> IR (.xml, .bin)
このプロジェクトの目的はリアルタイムでシングルステージの顔検出モデル、DBFaceをIntel(r) Distribution of OpenVINO(tm) Toolkit上で実行できるようにすることです。
Original DBFace GitHub site:https://github.com/dlunion/DBFace
元の開発者はPyTorchを使ってモデルの学習を行っています。そのためPyTorchモデルからOpenVINO IRモデルへの変換を行わなくてはなりません。 IRモデルを得るためには2つの変換ステップを要します。
PyTorch (.pth) -> ONNX (.onnx) -> IR (.xml, .bin)
Detection result with a 4VGA (1280x960) input picture
- Intel Distribution of OpenVINO toolkit 2020.2 (or newer)
- Model Downloader / Model Converter setup
Model Downloader guide
pip3 -r${INTEL_OPENVINO_DIR}/deployment_tools/tools/model_downloader/requirements.inpip3 -r${INTEL_OPENVINO_DIR}/deployment_tools/tools/model_downloader/requirements-pytorch.in
If you fail to install PyTorch, go to PyTorch official web site and follow theQUICK START LOCALLY
guide to install it. You need to have PyTorch >=1.4.
DownloadDBFace.py
anddbface.pth
fromoriginal developer's GitHub page.
Usepytorch_to_onnx.py
in themodel_downloader
directory.
python3${INTEL_OPENVINO_DIR}/deployment_tools/tools/model_downloader/pytorch_to_onnx.py \ --model-name DBFace \ --weights dbface.pth \ --import-module DBFace \ --input-shape 1,3,320,320 \ --output-file dbface.onnx \ --input-names x \ --output-names sigmoid_hm,tlrb,landmark
Hint: You can get the input and output node names from the model source code (in this case,DBFace.py
in themodel
directory)
defforward(self,x):out=self.hs1(self.bn1(self.conv1(x))) :returnsigmoid_hm,tlrb,landmark
UseModel Optimizer (MO)
to convert the ONNX model into IR model.
python3${INTEL_OPENVINO_DIR}/deployment_tools/model_optimizer/mo.py \ --input_model dbface.onnx \ --mean_values [180,154,150] \ --scale_values [73.7,70.0,70.9] \ --input_shape [1,3,960,1280] \ --output_dir dbface-4vga \ --data_type FP16
Hint: You can change the input shape with--input_shape
option.
Hint: You can find the appropriate parameters (--mean_values
and--scale_values
) for input data preprocessing from the original source code (in this case, line 36-40 inmain.py
from the origianl GitHub site)
mean= [0.408,0.447,0.47]std= [0.289,0.274,0.278]image=common.pad(image)image= ((image/255.0-mean)/std).astype(np.float32)
python3 dbface-infer.py -m model.xml -i input_image
A webCam #0 will be used when you specify 'cam' as the input file name.output.jpg
will be ganarated in the current directry. (non-webCam version only)
Command line example:
$ python3 dbface-infer.py -m dbface-4vga/dbface.xml -i image.jpg $ python3 dbface-infer.py -m dbface-vga/dbface.xml -i cam
- Ubuntu 18.04 / Windows 10 1909
- OpenVINO 2020.3 LTS
About
Describes how to run DBFace, a real-time, single-shot face detection model on Intel OpenVINO
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors3
Uh oh!
There was an error while loading.Please reload this page.