Khadas Docs

Amazing Khadas, always amazes you!

User Tools

Site Tools


products:sbc:vim4:npu:demos:facenet

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
products:sbc:vim4:npu:demos:facenet [2024/10/28 21:12]
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>6}} {{indexmenu_n>6}}
 +
 +===== 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.
 +
 +{{:products:sbc:vim4:npu:demos:facenet-demo-output.webp?400|}}
 +
 ===== Get Source Code ===== ===== Get Source Code =====
  
Line 23: Line 35:
 ``` ```
  
-===== Get Convert Tool =====+==== Get Convert Tool ==== 
 + 
 +Download Tool from [[gh>khadas/vim4_npu_sdk]].
  
 ```shell ```shell
 $ git lfs install $ git lfs install
-$ git lfs clone https://gitlab.com/khadas/vim4_npu_sdk.git+$ git lfs clone https://github.com/khadas/vim4_npu_sdk
 $ cd vim4_npu_sdk $ cd vim4_npu_sdk
 $ ls $ ls
-adla-toolkit-binary  adla-toolkit-binary-1.2.0. convert-in-docker.sh  Dockerfile  docs  README.md+adla-toolkit-binary  adla-toolkit-binary-3.1.7. convert-in-docker.sh  Dockerfile  docs  README.md
 ``` ```
  
Line 37: Line 51:
   * ''adla-toolkit-binary/demo'' - Conversion examples   * ''adla-toolkit-binary/demo'' - Conversion examples
  
-==== Get conversion tool ====+<WRAP important> 
 +If your kernel is older than 241129, please use branch npu-ddk-1.7.5.5. 
 +</WRAP>
  
-Download Tool from [[gl>khadas/vim4_npu_sdk]]. +==== Convert ====
- +
-```shell +
-$ git clone https://gitlab.com/khadas/vim4_npu_sdk +
-```+
  
 After training model, modify ''facenet-pytorch/nets/facenet.py'' as follows. After training model, modify ''facenet-pytorch/nets/facenet.py'' as follows.
Line 98: Line 110:
         --dtypes "float32" \         --dtypes "float32" \
         --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 "0,0,0,255"  \         --channel-mean-value "0,0,0,255"  \
Line 122: Line 134:
 $ git clone https://github.com/khadas/vim4_npu_applications $ git clone https://github.com/khadas/vim4_npu_applications
 ``` ```
 +
 +<WRAP important>
 +If your kernel is older than 241129, please use version before tag ddk-3.4.7.7.
 +</WRAP>
  
 ==== Install dependencies ==== ==== Install dependencies ====
Line 147: Line 163:
  
 # Run mode 1 # Run mode 1
-sudo ./facenet -m ../data/facenet_int8.adla -p 1+$ ./facenet -m ../data/facenet_int8.adla -p 1
 ``` ```
  
Line 154: Line 170:
 ```shell ```shell
 # Run mode 2 # Run mode 2
-sudo ./facenet -m ../data/model/facenet_int8.adla -p ../data/img/lin_2.jpg+$ ./facenet -m ../data/model/facenet_int8.adla -p ../data/img/lin_2.jpg
 ``` ```
  
 +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.
Last modified: 2024/10/28 21:12 by louis