pub struct ModelHub { /* private fields */ }Expand description
Hub per il download e la cache locale dei modelli ONNX.
Tutti i file finiscono in <cache_dir>/<version>/:
det.onnx— detection modelrec.onnx— recognition modelrec_inference.yml— config rec (contiene character_dict inline)dict.txt— caratteri estratti dal YML (una riga per char)
Implementations§
Source§impl ModelHub
impl ModelHub
Sourcepub fn new(cache_dir: impl Into<PathBuf>) -> Self
pub fn new(cache_dir: impl Into<PathBuf>) -> Self
Crea un hub con la directory di cache specificata.
Sourcepub fn with_default_cache() -> Result<Self, OcrError>
pub fn with_default_cache() -> Result<Self, OcrError>
Crea un hub con la directory di cache di default del sistema:
- Windows:
%LOCALAPPDATA%\ppocr-rs\models\ - macOS/Linux:
$HOME/.cache/ppocr-rs/models/
Sourcepub fn ensure(&self, version: PpOcrVersion) -> Result<ModelPaths, OcrError>
pub fn ensure(&self, version: PpOcrVersion) -> Result<ModelPaths, OcrError>
Assicura che i modelli per la versione richiesta siano presenti.
Scarica da HuggingFace se mancanti (richiede feature fetch-models).
Il download è bloccante — esegui su un thread secondario in GUI o in runtime async.
Sourcepub fn ensure_single(
&self,
model: PpStructureModel,
) -> Result<StructureModelPaths, OcrError>
pub fn ensure_single( &self, model: PpStructureModel, ) -> Result<StructureModelPaths, OcrError>
Scarica (o riusa dalla cache) un singolo modello PP-StructureV3.
Tutti i file finiscono in <cache_dir>/<model.dir_name()>/:
inference.onnx— sempre presenteinference.yml— solo se il modello ha vocabolario inlinedict.txt— estratto dall’yml (per SLANeXt)
§Esempio
use ppocr_rs::{ModelHub, PpStructureModel};
let hub = ModelHub::with_default_cache().unwrap();
let paths = hub.ensure_single(PpStructureModel::TableCls).unwrap();
// usa paths.onnx con TableTypeClassifier::from_path(paths.onnx)Auto Trait Implementations§
impl Freeze for ModelHub
impl RefUnwindSafe for ModelHub
impl Send for ModelHub
impl Sync for ModelHub
impl Unpin for ModelHub
impl UnsafeUnpin for ModelHub
impl UnwindSafe for ModelHub
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.