优化vision demo

This commit is contained in:
deng_wu_jie
2025-09-11 09:52:24 +08:00
parent e889ac42dc
commit d63e36cd99
4 changed files with 8 additions and 10 deletions

View File

@@ -136,7 +136,7 @@
<dependency> <dependency>
<groupId>ai.djl.tensorflow</groupId> <groupId>ai.djl.tensorflow</groupId>
<artifactId>tensorflow-native-cpu</artifactId> <artifactId>tensorflow-native-cpu</artifactId>
<classifier>win-x86_64</classifier> <classifier>${djl.platform.windows-x86_64}</classifier>
<scope>runtime</scope> <scope>runtime</scope>
<version>2.16.1</version> <version>2.16.1</version>
</dependency> </dependency>
@@ -144,7 +144,7 @@
<dependency> <dependency>
<groupId>ai.djl.mxnet</groupId> <groupId>ai.djl.mxnet</groupId>
<artifactId>mxnet-native-mkl</artifactId> <artifactId>mxnet-native-mkl</artifactId>
<classifier>win-x86_64</classifier> <classifier>${djl.platform.windows-x86_64}</classifier>
<scope>runtime</scope> <scope>runtime</scope>
<version>1.9.1</version> <version>1.9.1</version>
</dependency> </dependency>
@@ -179,6 +179,7 @@
<classifier>${javacv.platform.linux-x86_64}</classifier> <classifier>${javacv.platform.linux-x86_64}</classifier>
</dependency> </dependency>
<!--PyTorch离线平台依赖-->
<dependency> <dependency>
<groupId>ai.djl.pytorch</groupId> <groupId>ai.djl.pytorch</groupId>
<artifactId>pytorch-native-cpu</artifactId> <artifactId>pytorch-native-cpu</artifactId>
@@ -190,14 +191,14 @@
<dependency> <dependency>
<groupId>ai.djl.tensorflow</groupId> <groupId>ai.djl.tensorflow</groupId>
<artifactId>tensorflow-native-cpu</artifactId> <artifactId>tensorflow-native-cpu</artifactId>
<classifier>linux-x86_64</classifier> <classifier>${djl.platform.linux-x86_64}</classifier>
<scope>runtime</scope> <scope>runtime</scope>
<version>2.16.1</version> <version>2.16.1</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>ai.djl.mxnet</groupId> <groupId>ai.djl.mxnet</groupId>
<artifactId>mxnet-native-mkl</artifactId> <artifactId>mxnet-native-mkl</artifactId>
<classifier>linux-x86_64</classifier> <classifier>${djl.platform.linux-x86_64}</classifier>
<scope>runtime</scope> <scope>runtime</scope>
<version>1.9.1</version> <version>1.9.1</version>
</dependency> </dependency>

View File

@@ -78,7 +78,7 @@ public class InstanceSegDemo {
Image image = SmartImageFactory.getInstance().fromFile(Paths.get("src/main/resources/dog_bike_car.jpg")); Image image = SmartImageFactory.getInstance().fromFile(Paths.get("src/main/resources/dog_bike_car.jpg"));
R<DetectionResponse> result = detectorModel.detect(image); R<DetectionResponse> result = detectorModel.detect(image);
if(result.isSuccess()){ if(result.isSuccess()){
log.info("实例分割结果:{}", result.getData()); log.info("实例分割结果:{}", JSONObject.toJSONString(result.getData()));
}else{ }else{
log.info("实例分割失败:{}", result.getMessage()); log.info("实例分割失败:{}", result.getMessage());
} }

View File

@@ -41,14 +41,12 @@ public class PoseDetDemo {
* 获取姿态估计模型 * 获取姿态估计模型
* 注意事项: * 注意事项:
* 1、更多模型请查看文档http://doc.smartjavaai.cn * 1、更多模型请查看文档http://doc.smartjavaai.cn
* 2、模型可检测物体请查看模型同目录文件synset.txt
*/ */
public PoseModel getModel(){ public PoseModel getModel(){
PoseModelConfig config = new PoseModelConfig(); PoseModelConfig config = new PoseModelConfig();
//姿态估计模型切换模型需要同时修改modelEnum及modelPath //姿态估计模型切换模型需要同时修改modelEnum及modelPath
config.setModelEnum(PoseModelEnum.YOLOV8N_POSE_PT); config.setModelEnum(PoseModelEnum.YOLO11N_POSE_PT);
//模型所在路径synset.txt也需要放在同目录下 config.setModelPath("/Users/wenjie/Documents/develop/model/vision/pose/yolo11n-pose-pt");
config.setModelPath("/Users/wenjie/Documents/develop/model/vision/pose/yolo11n-pose-onnx/yolo11n-pose.onnx");
config.setDevice(device); config.setDevice(device);
//置信度阈值 //置信度阈值
config.setThreshold(0.25f); config.setThreshold(0.25f);

View File

@@ -53,7 +53,6 @@ public class SemSegDemo {
config.setModelPath("/Users/wenjie/Documents/develop/model/vision/semseg/deeplabv3/deeplabv3.pt"); config.setModelPath("/Users/wenjie/Documents/develop/model/vision/semseg/deeplabv3/deeplabv3.pt");
// 指定允许的类别 // 指定允许的类别
// config.setAllowedClasses(Arrays.asList("person","car")); // config.setAllowedClasses(Arrays.asList("person","car"));
//指定返回检测数量
config.setDevice(device); config.setDevice(device);
return SemSegModelFactory.getInstance().getModel(config); return SemSegModelFactory.getInstance().getModel(config);
} }