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 [2024/01/04 05:22] louis |
products:sbc:vim4:npu:demos:facenet [2025/06/11 22:05] (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 ====== | ||
| {{indexmenu_n> | {{indexmenu_n> | ||
| + | |||
| + | ===== Introduction ===== | ||
| + | |||
| + | FaceNet is a face recognition model. It will convert a face image into a feature map. Compare the feature map between image and face database. Here are two judgment indicators, cosine similarity and Euclidean distance. The closer the cosine similarity is to 1 and the closer the Euclidean distance is to 0, the more similar is between two faces. | ||
| + | |||
| + | Here takes **lin_1.jpg** as example. Inference results on VIM4. | ||
| + | |||
| + | {{: | ||
| + | |||
| ===== Get Source Code ===== | ===== Get Source Code ===== | ||
| Line 17: | Line 29: | ||
| 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 92: | Line 114: | ||
| --channel-mean-value " | --channel-mean-value " | ||
| --source-file facenet_dataset.txt | --source-file facenet_dataset.txt | ||
| - | --iterations | + | --iterations |
| --disable-per-channel False \ | --disable-per-channel False \ | ||
| --batch-size 1 --target-platform PRODUCT_PID0XA003 | --batch-size 1 --target-platform PRODUCT_PID0XA003 | ||
| ``` | ``` | ||
| - | |||
| - | <WRAP important > | ||
| - | Please prepare about 500 pictures for quantification. If the pictures size is smaller than model input size, please resize pictures to input size before quantification. | ||
| - | </ | ||
| Run '' | Run '' | ||
| Line 117: | Line 135: | ||
| ``` | ``` | ||
| - | <WRAP important > | + | <WRAP important> |
| - | If your kernel | + | If your kernel is older than 241129, please use version before |
| </ | </ | ||
| Line 145: | Line 163: | ||
| # Run mode 1 | # Run mode 1 | ||
| - | $ sudo ./facenet -m ../ | + | $ ./facenet -m ../ |
| ``` | ``` | ||
| Line 152: | Line 170: | ||
| ```shell | ```shell | ||
| # Run mode 2 | # Run mode 2 | ||
| - | $ sudo ./facenet -m ../ | + | $ ./facenet -m ../ |
| ``` | ``` | ||
| + | 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. | ||