refactor(ai):重构分割模型包装类继承结构- 将 Anime2ModelWrapper、Anime2VividModelWrapper 和 AnimeModelWrapper 改为继承自 VividModelWrapper 基类
- 移除重复的 ResultFiles 内部类和相关工具方法实现 - Anime2Segmenter 和 AnimeSegmenter 继承自抽象基类 Segmenter - Anime2SegmentationResult与 AnimeSegmentationResult 继承 SegmentationResult - 重命名 LabelPalette 为 BiSeNetLabelPalette 并调整其引用 - 更新模型路径配置以匹配新的文件命名约定 - 删除冗余的 getLabels() 和 getPalette() 方法定义 - 简化 segmentAndSave 方法中的类型转换逻辑- 移除已被继承方法替代的手动资源管理代码 - 调整 import 语句以反映包结构调整- 清理不再需要的独立主测试函数入口点- 修改字段访问权限以符合继承设计模式 - 替换具体的返回类型为更通用的 SegmentationResult 接口- 整合公共功能至基类减少子类间重复代码 - 统一分割后处理流程提高模块复用性 - 引入泛型支持增强 Wrapper 类型安全性 - 更新注释文档保持与最新架构同步 - 优化异常处理策略统一关闭资源方式 - 规范文件命名规则便于未来维护扩展 - 提取共通逻辑到父类降低耦合度 - 完善类型检查避免运行时 ClassCastException 风险
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
package com.chuangzhou.vivid2D.test;
|
||||
|
||||
import com.chuangzhou.vivid2D.ai.face_parsing.VividModelWrapper;
|
||||
import com.chuangzhou.vivid2D.ai.face_parsing.BiSeNetVividModelWrapper;
|
||||
|
||||
import java.io.PrintStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
@@ -14,7 +14,7 @@ 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"));
|
||||
BiSeNetVividModelWrapper wrapper = BiSeNetVividModelWrapper.load(Paths.get("C:\\models\\bisenet_face_parsing.pt"));
|
||||
|
||||
// 使用 BiSeNet 人脸解析模型的 18 个非背景标签
|
||||
Set<String> faceLabels = Set.of(
|
||||
|
||||
Reference in New Issue
Block a user