From 45cb7a9edc12e799d78a003b8556f8df6159899a Mon Sep 17 00:00:00 2001 From: dengwenjie <775747758@qq.com> Date: Thu, 20 Mar 2025 21:12:35 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E7=A6=BB=E7=BA=BF=E6=97=A0?= =?UTF-8?q?=E6=B3=95=E4=BD=BF=E7=94=A8=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- examples/face_offline.md | 2 +- examples/pom.xml | 2 +- .../java/smartai/examples/face/FaceDemo.java | 10 ++-- pom.xml | 49 +++++++++++++++++-- smartjavaai-common/pom.xml | 2 +- smartjavaai-face/pom.xml | 4 +- 7 files changed, 58 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 184097a..b66cc85 100644 --- a/README.md +++ b/README.md @@ -81,7 +81,7 @@ ink.numberone smartjavaai-face - 1.0.3 + 1.0.4 ``` diff --git a/examples/face_offline.md b/examples/face_offline.md index 908f3a5..73991bf 100644 --- a/examples/face_offline.md +++ b/examples/face_offline.md @@ -11,7 +11,7 @@ ink.numberone smartjavaai-face - 1.0.3 + 1.0.4 ``` diff --git a/examples/pom.xml b/examples/pom.xml index a75b7e9..338ca0e 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -43,7 +43,7 @@ ink.numberone smartjavaai-face - 1.0.3 + 1.0.4 diff --git a/examples/src/main/java/smartai/examples/face/FaceDemo.java b/examples/src/main/java/smartai/examples/face/FaceDemo.java index 0699cec..bd8da30 100644 --- a/examples/src/main/java/smartai/examples/face/FaceDemo.java +++ b/examples/src/main/java/smartai/examples/face/FaceDemo.java @@ -29,8 +29,9 @@ public class FaceDemo { public static void main(String[] args) { try { - //detectFace2(); verifyIDCard(); + //detectFace2(); + //verifyIDCard(); } catch (Exception e) { e.printStackTrace(); } @@ -113,7 +114,7 @@ public class FaceDemo { sw.reset(); sw.start(); //提取身份证人脸特征(图片仅供测试) - float[] featureIdCard = currentAlgorithm.featureExtraction("src/main/resources/kana1.jpg"); + float[] featureIdCard = currentAlgorithm.featureExtraction("src/main/resources/MJ_20250213_155245.png"); sw.stop(); logger.info("人脸特征提取耗时:" + sw.getTime() + "ms"); //提取身份证人脸特征(从图片流获取) @@ -121,9 +122,10 @@ public class FaceDemo { //float[] featureIdCard = currentAlgorithm.featureExtraction(new FileInputStream(input)); logger.info("身份证人脸特征:{}", JSONObject.toJSONString(featureIdCard)); //提取实时人脸特征(图片仅供测试) - float[] realTimeFeature = currentAlgorithm.featureExtraction("src/main/resources/kana2.jpg"); + float[] realTimeFeature = currentAlgorithm.featureExtraction("src/main/resources/MJ_20250213_155228.png"); logger.info("实时人脸特征:{}", JSONObject.toJSONString(realTimeFeature)); if(realTimeFeature != null){ + System.out.println("相似度:" + currentAlgorithm.calculSimilar(featureIdCard, realTimeFeature)); if(currentAlgorithm.calculSimilar(featureIdCard, realTimeFeature) > 0.8){ logger.info("人脸核验通过"); }else{ @@ -151,7 +153,7 @@ public class FaceDemo { //retinaface: https://resources.djl.ai/test-models/pytorch/retinaface.zip //ultralightfastgenericface: https://resources.djl.ai/test-models/pytorch/ultranet.zip //改为模型存放路径 - config.setModelPath("/Users/xxx/Documents/develop/face_model/retinaface.pt"); + config.setModelPath("/Users/wenjie/Documents/develop/face_model/retinaface.pt"); //创建人脸算法 FaceAlgorithm currentAlgorithm = FaceAlgorithmFactory.createFaceAlgorithm(config); //使用图片路径检测 diff --git a/pom.xml b/pom.xml index 8319a88..2d0b4c5 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ ink.numberone smartjavaai-parent - 1.0.3 + 1.0.4 pom SmartJavaAI @@ -34,13 +34,13 @@ ink.numberone smartjavaai-common - 1.0.3 + 1.0.4 ink.numberone smartjavaai-face - 1.0.3 + 1.0.4 @@ -133,6 +133,49 @@ commons-lang3 3.9 + + + ai.djl.pytorch + pytorch-engine + 0.32.0 + runtime + + + + ai.djl.pytorch + pytorch-native-cpu + win-x86_64 + runtime + 2.5.1 + + + ai.djl.pytorch + pytorch-native-cpu + linux-x86_64 + runtime + 2.5.1 + + + ai.djl.pytorch + pytorch-native-cpu-precxx11 + linux-aarch64 + runtime + 2.5.1 + + + ai.djl.pytorch + pytorch-native-cpu + osx-aarch64 + 2.5.1 + runtime + + + ai.djl.pytorch + pytorch-jni + 2.5.1-0.32.0 + runtime + + https://github.com/geekwenjie/SmartJavaAI diff --git a/smartjavaai-common/pom.xml b/smartjavaai-common/pom.xml index 038cee1..dc00073 100644 --- a/smartjavaai-common/pom.xml +++ b/smartjavaai-common/pom.xml @@ -6,7 +6,7 @@ ink.numberone smartjavaai-parent - 1.0.3 + 1.0.4 smartjavaai-common diff --git a/smartjavaai-face/pom.xml b/smartjavaai-face/pom.xml index a7dfe82..acfe021 100644 --- a/smartjavaai-face/pom.xml +++ b/smartjavaai-face/pom.xml @@ -6,11 +6,11 @@ ink.numberone smartjavaai-parent - 1.0.3 + 1.0.4 smartjavaai-face - 1.0.3 + 1.0.4 smartjavaai-face SmartJavaAI https://github.com/geekwenjie/SmartJavaAI