docs(core): 为 ddddocr-core 全量补充并精简 Rustdoc 文档
This commit is contained in:
@@ -1,19 +1,20 @@
|
||||
//! 推理引擎统一抽象接口。
|
||||
|
||||
use crate::error::TensorError;
|
||||
use crate::types::{ModelInfo, TensorInfo};
|
||||
use crate::{DetOutput, ModelMetadata, OcrOutput};
|
||||
use std::path::Path;
|
||||
|
||||
|
||||
/// 查询模型输入/输出信息的接口。
|
||||
pub trait Info {
|
||||
fn input_info(&self) -> crate::error::Result<Vec<TensorInfo>>;
|
||||
fn output_info(&self) -> crate::error::Result<Vec<TensorInfo>>;
|
||||
fn model_info(&self) -> crate::error::Result<ModelInfo>;
|
||||
}
|
||||
|
||||
/// 核心层定义的统一推理引擎接口。
|
||||
/// 未来的 ddddocr-tract 和 ddddocr-ort 都必须实现这个 Trait
|
||||
/// 推理引擎统一抽象接口,由 ddddocr-tract、ddddocr-ort 等引擎 crate 实现。
|
||||
pub trait InferenceEngine {
|
||||
/// 关联类型:具体的 Session 需要声明自己到底产出什么枚举
|
||||
/// 引擎产出的输出枚举(OCR 为 [`crate::OcrOutput`],检测为 [`crate::DetOutput`])。
|
||||
type Output;
|
||||
fn inference(
|
||||
&self,
|
||||
@@ -21,12 +22,15 @@ pub trait InferenceEngine {
|
||||
) -> crate::error::Result<Self::Output, TensorError>;
|
||||
}
|
||||
|
||||
/// OCR 引擎接口:输出 [`crate::OcrOutput`],并提供模型元数据。
|
||||
pub trait OcrEngine: InferenceEngine<Output = OcrOutput> + Info {
|
||||
fn metadata(&self) -> &ModelMetadata;
|
||||
}
|
||||
|
||||
/// 目标检测引擎接口:输出 [`crate::DetOutput`]。
|
||||
pub trait DetEngine: InferenceEngine<Output = DetOutput> {}
|
||||
|
||||
/// 模型加载器:从本地路径或字节流构建引擎会话。
|
||||
pub trait Loader {
|
||||
type Session;
|
||||
type Error;
|
||||
|
||||
Reference in New Issue
Block a user