feat(ai): 集成动漫人物分割与面部解析AI模型- 添加 DJL 深度学习框架依赖项以支持 PyTorch 和 ONNX Runtime 引擎

- 实现 Anime2VividModelWrapper 封装类用于动漫人物前景背景分离
- 开发 AnimeModelWrapper用于精细的动漫面部特征(如头发、眼睛)分割
- 创建配套的标签调色板和结果处理工具类提升可视化效果
- 增加多个测试用例验证不同AI模型的推理及文件输出功能
- 支持通过 synset.txt 自定义模型标签并增强命令行可测试性
This commit is contained in:
tzdwindows 7
2025-10-27 18:39:13 +08:00
parent f2cb74379e
commit a725e7eb23
18 changed files with 2414 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
package com.chuangzhou.vivid2D.test;
import com.chuangzhou.vivid2D.ai.face_parsing.VividModelWrapper;
import java.io.PrintStream;
import java.nio.charset.StandardCharsets;
import java.nio.file.Paths;
import java.util.Set;
/**
* 测试人脸解析模型
*/
public class AITest {
public static void main(String[] args) throws Exception {
System.setOut(new PrintStream(System.out, true, StandardCharsets.UTF_8));
System.setErr(new PrintStream(System.err, true, StandardCharsets.UTF_8));
VividModelWrapper wrapper = VividModelWrapper.load(Paths.get("C:\\models\\bisenet_face_parsing.pt"));
// 使用 BiSeNet 人脸解析模型的 18 个非背景标签
Set<String> faceLabels = Set.of(
"skin", "nose", "eye_left", "eye_right", "eyebrow_left",
"eyebrow_right", "ear_left", "ear_right", "mouth", "lip_upper",
"lip_lower", "hair", "hat", "earring", "necklace", "clothes",
"facial_hair", "neck"
);
wrapper.segmentAndSave(
Paths.get("C:\\Users\\Administrator\\Desktop\\b_f4881214f0d18b6cf848b6736f554821.png").toFile(),
faceLabels,
Paths.get("C:\\models\\out")
);
}
}