This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
products:sbc:vim4:npu:demos:facenet [2023/09/18 01:53] sravan [Build virtual environment] |
products:sbc:vim4:npu:demos:facenet [2025/01/08 22:31] (current) louis |
||
---|---|---|---|
Line 1: | Line 1: | ||
~~tag> NPU FaceNet VIM4 PyTorch~~ | ~~tag> NPU FaceNet VIM4 PyTorch~~ | ||
+ | |||
+ | **Doc for version ddk-3.4.7.7** | ||
+ | |||
====== FaceNet PyTorch VIM4 Demo - 6 ====== | ====== FaceNet PyTorch VIM4 Demo - 6 ====== | ||
Line 17: | Line 20: | ||
Follow Docker official documentation to install Docker: [[https:// | Follow Docker official documentation to install Docker: [[https:// | ||
- | Then fetch the prebuilt NPU Docker | + | Follow |
```shell | ```shell | ||
- | $ docker pull yanwyb/npu:v1 | + | docker pull numbqq/npu-vim4 |
- | $ docker run -it --name | + | |
- | -v / | + | |
- | -v / | + | |
- | yanwyb/ | + | |
``` | ``` | ||
- | ==== Get conversion tool ==== | + | ==== Get Convert Tool ==== |
- | Download Tool from [[gl> | + | Download Tool from [[gh> |
```shell | ```shell | ||
- | $ git clone https://gitlab.com/ | + | $ git lfs install |
+ | $ git lfs clone https://github.com/ | ||
+ | $ cd vim4_npu_sdk | ||
+ | $ ls | ||
+ | adla-toolkit-binary | ||
``` | ``` | ||
+ | |||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | |||
+ | <WRAP important> | ||
+ | If your kernel is older than 241129, please use branch npu-ddk-1.7.5.5. | ||
+ | </ | ||
+ | |||
+ | ==== Convert ==== | ||
After training model, modify '' | After training model, modify '' | ||
Line 52: | Line 65: | ||
``` | ``` | ||
- | Create a python | + | Create a Python |
```python export.py | ```python export.py | ||
Line 88: | Line 101: | ||
--dtypes " | --dtypes " | ||
--inference-input-type float32 \ | --inference-input-type float32 \ | ||
- | --inference-output-type float32 \ | + | --inference-output-type float32 \ |
--quantize-dtype int8 --outdir onnx_output | --quantize-dtype int8 --outdir onnx_output | ||
--channel-mean-value " | --channel-mean-value " | ||
Line 97: | Line 110: | ||
``` | ``` | ||
- | Run '' | + | Run '' |
```shell | ```shell | ||
Line 112: | Line 125: | ||
$ git clone https:// | $ git clone https:// | ||
``` | ``` | ||
+ | |||
+ | <WRAP important> | ||
+ | If your kernel is older than 241129, please use version before tag ddk-3.4.7.7. | ||
+ | </ | ||
==== Install dependencies ==== | ==== Install dependencies ==== | ||
Line 124: | Line 141: | ||
=== Picture input demo === | === Picture input demo === | ||
- | There are two modes of this demo. One is converting face images into feature vectors and saving vectors in face library. Another is comparing input face image with faces in library and outputting Euclidean distance and cosine similarity. | + | There are two modes of this demo. One is converting face images into feature vectors and saving vectors in the face library. Another is comparing input face image with faces in the library and outputting Euclidean distance and cosine similarity. |
Put '' | Put '' | ||
Line 130: | Line 147: | ||
```shell | ```shell | ||
# Compile | # Compile | ||
- | $ cd vim4_npu_applications/ | + | $ cd vim4_npu_applications/ |
$ mkdir build | $ mkdir build | ||
$ cd build | $ cd build | ||
Line 137: | Line 154: | ||
# Run mode 1 | # Run mode 1 | ||
- | $ sudo ./facenet -m ../ | + | $ ./facenet -m ../ |
``` | ``` | ||
Line 144: | Line 161: | ||
```shell | ```shell | ||
# Run mode 2 | # Run mode 2 | ||
- | $ sudo ./facenet -m ../ | + | $ ./facenet -m ../data/model/ |
``` | ``` | ||
+ | {{: | ||
+ | |||
+ | Here are two comparison methods, **Euclidean distance** and **cosine similarity**. | ||
+ | |||
+ | **Euclidean distance** is smaller, more similar between two faces. | ||
+ | |||
+ | **Cosine similarity** is closer to 1, more similar between two faces. |