Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Describes how to run DBFace, a real-time, single-shot face detection model on Intel OpenVINO

License

NotificationsYou must be signed in to change notification settings

yas-sim/dbface-on-openvino

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 

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 pictureoutput

1. Prerequisites

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.

2. Download DBFace PyTorch model and weight

DownloadDBFace.py anddbface.pth fromoriginal developer's GitHub page.

3. Convert PyTorch model into ONNX model

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

4. Convert ONNX model into OpenVINO IR model

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)

5. Run sample program

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

6. Test Environment

  • Ubuntu 18.04 / Windows 10 1909
  • OpenVINO 2020.3 LTS

See Also

About

Describes how to run DBFace, a real-time, single-shot face detection model on Intel OpenVINO

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors3

  •  
  •  
  •  

[8]ページ先頭

©2009-2025 Movatter.jp