pub trait ModelAdapter:
Send
+ Sync
+ Debug {
type Task: Task;
// Required methods
fn info(&self) -> AdapterInfo;
fn execute(
&self,
input: <Self::Task as Task>::Input,
config: Option<&<Self::Task as Task>::Config>,
) -> Result<<Self::Task as Task>::Output, OCRError>;
// Provided methods
fn schema(&self) -> TaskSchema { ... }
fn validate_compatibility(
&self,
schema: &TaskSchema,
) -> Result<(), OCRError> { ... }
fn supports_batching(&self) -> bool { ... }
fn recommended_batch_size(&self) -> usize { ... }
}Expand description
Core trait for model adapters.
Adapters bridge the gap between task interfaces and concrete model implementations. They handle model-specific preprocessing, inference, and postprocessing while conforming to the task’s input/output schema.
Required Associated Types§
Required Methods§
Sourcefn info(&self) -> AdapterInfo
fn info(&self) -> AdapterInfo
Returns information about this adapter.
Provided Methods§
Sourcefn schema(&self) -> TaskSchema
fn schema(&self) -> TaskSchema
Returns the schema that this adapter conforms to.
Sourcefn validate_compatibility(&self, schema: &TaskSchema) -> Result<(), OCRError>
fn validate_compatibility(&self, schema: &TaskSchema) -> Result<(), OCRError>
Sourcefn supports_batching(&self) -> bool
fn supports_batching(&self) -> bool
Returns whether this adapter can handle batched inputs efficiently.
Sourcefn recommended_batch_size(&self) -> usize
fn recommended_batch_size(&self) -> usize
Returns the recommended batch size for this adapter.