mirror of
https://github.com/geekwenjie/SmartJavaAI.git
synced 2026-09-10 03:28:49 +00:00
- 【人脸检测】新增6个模型(MTCNN、YOLOV5、RetinaFace小尺寸版),大幅提升性能
- 【人脸识别】新增Seetaface6轻量模型 - 【目标检测】支持视频流目标检测(rtsp、视频文件等) - 【目标检测】支持tensorflow2目标检测模型 - 【目标检测】新增行人检测模型(yolo-person) - 【通用视觉】新增4个动作识别模型 - 【通用视觉】新增语义分割模型 - 【通用视觉】新增5个实例分割模型(含yolov8-seg、yolov11-seg) - 【通用视觉】新增yolo-obb11旋转框检测(含yolov11-obb) - 【通用视觉】新增5个姿态估计模型(含yolov8-pose、yolov11-pose)
This commit is contained in:
@@ -34,7 +34,7 @@
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>cn.smartjavaai</groupId>
|
||||
<artifactId>smartjavaai-bom</artifactId>
|
||||
<artifactId>bom</artifactId>
|
||||
<version>${smartjavaai.version}</version>
|
||||
<type>pom</type>
|
||||
<!-- 注意这里是import -->
|
||||
@@ -55,11 +55,7 @@
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>2.17.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-slf4j2-impl</artifactId>
|
||||
<version>2.24.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.testng</groupId>
|
||||
<artifactId>testng</artifactId>
|
||||
@@ -73,11 +69,7 @@
|
||||
<artifactId>logback-classic</artifactId>
|
||||
<version>1.2.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<version>1.7.30</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
@@ -94,14 +86,14 @@
|
||||
<!--翻译模块-->
|
||||
<dependency>
|
||||
<groupId>cn.smartjavaai</groupId>
|
||||
<artifactId>smartjavaai-translate</artifactId>
|
||||
<artifactId>translate</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>ai.djl.pytorch</groupId>
|
||||
<artifactId>pytorch-jni</artifactId>
|
||||
<version>2.7.1-0.34.0</version>
|
||||
<version>2.5.1-0.32.0</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
@@ -112,7 +104,7 @@
|
||||
<groupId>ai.djl.pytorch</groupId>
|
||||
<artifactId>pytorch-native-cpu</artifactId>
|
||||
<classifier>${djl.platform.windows-x86_64}</classifier>
|
||||
<version>2.7.1</version>
|
||||
<version>2.5.1</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
@@ -124,7 +116,15 @@
|
||||
<groupId>ai.djl.pytorch</groupId>
|
||||
<artifactId>pytorch-native-cpu</artifactId>
|
||||
<classifier>${djl.platform.linux-x86_64}</classifier>
|
||||
<version>2.7.1</version>
|
||||
<version>2.5.1</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>ai.djl.pytorch</groupId>
|
||||
<artifactId>pytorch-native-cpu-precxx11</artifactId>
|
||||
<classifier>${djl.platform.linux-x86_64}</classifier>
|
||||
<version>2.5.1</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
@@ -134,23 +134,23 @@
|
||||
<groupId>ai.djl.pytorch</groupId>
|
||||
<artifactId>pytorch-native-cpu</artifactId>
|
||||
<classifier>${djl.platform.osx-aarch64}</classifier>
|
||||
<version>2.7.1</version>
|
||||
<version>2.5.1</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- linux aarch64 平台 (保留对应平台的配置,可以减小包大小)-->
|
||||
|
||||
<dependency>
|
||||
<groupId>ai.djl.pytorch</groupId>
|
||||
<artifactId>pytorch-native-cpu-precxx11</artifactId>
|
||||
<classifier>${djl.platform.linux-aarch64}</classifier>
|
||||
<version>2.7.1</version>
|
||||
<artifactId>pytorch-native-cpu</artifactId>
|
||||
<classifier>linux-aarch64</classifier>
|
||||
<scope>runtime</scope>
|
||||
<version>2.5.1</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
@@ -179,16 +179,21 @@
|
||||
</build>
|
||||
|
||||
<repositories>
|
||||
<!-- <repository>-->
|
||||
<!-- <id>aliyunmaven</id>-->
|
||||
<!-- <name>阿里云公共仓库</name>-->
|
||||
<!-- <url>https://maven.aliyun.com/repository/public</url>-->
|
||||
<!-- <releases>-->
|
||||
<!-- <enabled>true</enabled>-->
|
||||
<!-- </releases>-->
|
||||
<!-- <snapshots>-->
|
||||
<!-- <enabled>false</enabled>-->
|
||||
<!-- </snapshots>-->
|
||||
<!-- </repository>-->
|
||||
|
||||
<repository>
|
||||
<id>aliyunmaven</id>
|
||||
<name>阿里云公共仓库</name>
|
||||
<url>https://maven.aliyun.com/repository/public</url>
|
||||
<releases>
|
||||
<enabled>true</enabled>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
<id>central</id>
|
||||
<url>https://repo1.maven.org/maven2/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
|
||||
@@ -18,34 +18,73 @@ import org.junit.Test;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* 翻译Demo
|
||||
* 支持 Meta AI 开源的 NLLB-200 模型,实现 200 多种语言之间的高质量互译。
|
||||
* NLLB-200官网地址:https://github.com/facebookresearch/fairseq/tree/nllb
|
||||
* 机器翻译Demo
|
||||
* 模型下载地址:https://pan.baidu.com/s/1wf7btnb4cyBFv7DB7baHnw?pwd=1234 提取码: 1234
|
||||
* 开发文档:http://doc.smartjavaai.cn/
|
||||
* @author dwj
|
||||
*/
|
||||
@Slf4j
|
||||
public class TranslationDemo {
|
||||
|
||||
//设备类型
|
||||
public static DeviceEnum device = DeviceEnum.CPU;
|
||||
|
||||
@BeforeClass
|
||||
public static void beforeAll() throws IOException {
|
||||
//修改缓存路径
|
||||
// Config.setCachePath("/Users/xxx/smartjavaai_cache");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取模型(NLLB)
|
||||
* @return
|
||||
*/
|
||||
public TranslationModel getNllbModel() {
|
||||
TranslationModelConfig config = new TranslationModelConfig();
|
||||
//指定翻译模型:NLLB,切换模型需同时修改modelEnum及modelPath
|
||||
config.setModelEnum(TranslationModeEnum.NLLB_MODEL);
|
||||
//指定模型路径,需将模型路径修改为本地的模型路径
|
||||
config.setModelPath("/Users/xxx/Documents/develop/model/trans/traced_translation_cpu.pt");
|
||||
config.setDevice(DeviceEnum.CPU);
|
||||
return TranslationModelFactory.getInstance().getModel(config);
|
||||
}
|
||||
|
||||
/**
|
||||
* 翻译
|
||||
* 获取中文模型(OPUS 中文->英文)
|
||||
* @return
|
||||
*/
|
||||
public TranslationModel getOPUSModelZH_EN() {
|
||||
TranslationModelConfig config = new TranslationModelConfig();
|
||||
//指定翻译模型,切换模型需同时修改modelEnum及modelPath
|
||||
config.setModelEnum(TranslationModeEnum.OPUS_MT_ZH_EN);
|
||||
//指定模型路径,需将模型路径修改为本地的模型路径
|
||||
config.setModelPath("/Users/wenjie/Documents/develop/model/trans/opus-mt-zh-en/traced_translation.pt");
|
||||
config.setDevice(DeviceEnum.CPU);
|
||||
return TranslationModelFactory.getInstance().getModel(config);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取中文模型(OPUS 英文->中文)
|
||||
* @return
|
||||
*/
|
||||
public TranslationModel getOPUSModelEN_ZH() {
|
||||
TranslationModelConfig config = new TranslationModelConfig();
|
||||
//指定翻译模型,切换模型需同时修改modelEnum及modelPath
|
||||
config.setModelEnum(TranslationModeEnum.OPUS_MT_EN_ZH);
|
||||
//指定模型路径,需将模型路径修改为本地的模型路径
|
||||
config.setModelPath("/Users/wenjie/Documents/develop/model/trans/opus-mt-en-zh/traced_translation.pt");
|
||||
config.setDevice(DeviceEnum.CPU);
|
||||
return TranslationModelFactory.getInstance().getModel(config);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 翻译(nllb模型)
|
||||
*/
|
||||
@Test
|
||||
public void translate() {
|
||||
public void nllbTranslate() {
|
||||
try {
|
||||
TranslationModelConfig config = new TranslationModelConfig();
|
||||
//指定翻译模型:NLLB
|
||||
config.setModelEnum(TranslationModeEnum.NLLB_MODEL);
|
||||
//指定模型路径,需将模型路径修改为本地的模型路径
|
||||
config.setModelPath("/Users/xxx/Documents/develop/model/trans/traced_translation_cpu.pt");
|
||||
TranslationModel translationModel = TranslationModelFactory.getInstance().getModel(config);
|
||||
TranslationModel translationModel = getNllbModel();
|
||||
//翻译参数
|
||||
TranslateParam translateParam = new TranslateParam();
|
||||
//输入文字
|
||||
@@ -74,28 +113,16 @@ public class TranslationDemo {
|
||||
}
|
||||
|
||||
/**
|
||||
* GPU 翻译
|
||||
* 翻译(opus 中文->英文)
|
||||
*/
|
||||
@Test
|
||||
public void translateGpu() {
|
||||
public void opusTranslate1() {
|
||||
try {
|
||||
TranslationModelConfig config = new TranslationModelConfig();
|
||||
//指定翻译模型:NLLB
|
||||
config.setModelEnum(TranslationModeEnum.NLLB_MODEL);
|
||||
//指定设备:GPU
|
||||
config.setDevice(DeviceEnum.GPU);
|
||||
//指定模型路径,需将模型路径修改为本地的 GPU 模型路径
|
||||
config.setModelPath("/Users/xxx/Documents/develop/model/trans/traced_translation_gpu.pt");
|
||||
//获取翻译模型
|
||||
TranslationModel translationModel = TranslationModelFactory.getInstance().getModel(config);
|
||||
TranslationModel translationModel = getOPUSModelZH_EN();
|
||||
//翻译参数
|
||||
TranslateParam translateParam = new TranslateParam();
|
||||
//输入文字
|
||||
translateParam.setInput("你好,欢迎使用SmartJavaAI!");
|
||||
//源语言:中文
|
||||
translateParam.setSourceLanguage(LanguageCode.ZHO_HANS);
|
||||
//目标语言:韩语
|
||||
translateParam.setTargetLanguage(LanguageCode.ENG_LATN);
|
||||
translateParam.setInput("SmartJavaAI是专为JAVA 开发者打造的一个功能丰富、开箱即用的 JAVA AI算法工具包");
|
||||
R<String> result = translationModel.translate(translateParam);
|
||||
if(result.isSuccess()){
|
||||
log.info("翻译结果:{}", result.getData());
|
||||
@@ -107,4 +134,28 @@ public class TranslationDemo {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 翻译(opus 英文->中文)
|
||||
*/
|
||||
@Test
|
||||
public void opusTranslate2() {
|
||||
try {
|
||||
TranslationModel translationModel = getOPUSModelEN_ZH();
|
||||
//翻译参数
|
||||
TranslateParam translateParam = new TranslateParam();
|
||||
//输入文字
|
||||
translateParam.setInput("You don't have to be machine learning expert to get started");
|
||||
R<String> result = translationModel.translate(translateParam);
|
||||
if(result.isSuccess()){
|
||||
log.info("翻译结果:{}", result.getData());
|
||||
}else{
|
||||
log.error("翻译失败:{}", result.getMessage());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user