refactor: 重构 core 包目录结构并消除旧版 mod.rs

- 优化 剥离 models,algo 层并平铺业务模块
- 重构 统一使用现代 filename.rs + 文件夹结构替代旧版 mod.rs
This commit is contained in:
2026-07-11 17:38:30 +08:00
parent ea7fb43a14
commit 4fd38022fd
22 changed files with 209 additions and 251 deletions

View File

@@ -1,4 +1,4 @@
use crate::loader::{ModelLoader, ModelSession, ModelType};
use crate::loader::ModelLoader;
use anyhow::Context;
use ddddocr_core::error::{DdddError, Result};
use ddddocr_core::{DetEngine, DetOutput, InferenceEngine};
@@ -10,15 +10,6 @@ pub struct DetSession {
pub session: RunnableModel<TypedFact, Box<dyn TypedOp>, Graph<TypedFact, Box<dyn TypedOp>>>,
}
impl ModelSession for DetSession {
fn get_model_type(&self) -> ModelType {
todo!()
}
fn desc(&self) -> String {
"Detection Model 加载成功".to_string()
}
}
impl DetSession {
pub fn new<P>(model_path: P) -> Result<Self>
where

View File

@@ -3,18 +3,6 @@ use ddddocr_core::error::Result;
use std::io::Cursor;
use tract_onnx::onnx;
use tract_onnx::prelude::*; // 引入核心层的统一错误类型
/// OCR 模型:包含路径和字符集
pub enum ModelType {
Ocr,
Det,
Custom,
}
// 定义统一的 trait
pub trait ModelSession {
fn get_model_type(&self) -> ModelType;
fn desc(&self) -> String;
}
pub struct ModelLoader {
pub session: RunnableModel<TypedFact, Box<dyn TypedOp>, Graph<TypedFact, Box<dyn TypedOp>>>,