pub struct LayoutModel { /* private fields */ }Implementations§
Source§impl LayoutModel
impl LayoutModel
Sourcepub fn load() -> Result<Self, String>
pub fn load() -> Result<Self, String>
Load the ONNX model from DOCLING_LAYOUT_ONNX. Without the override,
prefers .models/layout_heron_int8.onnx when present (the quantized
default; DOCLING_RS_FP32=1 opts out), else .models/layout_heron.onnx.
Sourcepub fn load_with(intra: usize) -> Result<Self, String>
pub fn load_with(intra: usize) -> Result<Self, String>
Like load but with an explicit intra-op thread count. A
parallel page-worker pool loads its helper models on a single thread each
and gets its speed-up from running pages concurrently instead.
Sourcepub fn predict_fp32_fallback(
&mut self,
img: LayoutSrc<'_>,
page_w: f32,
page_h: f32,
) -> Result<Option<Vec<Region>>, String>
pub fn predict_fp32_fallback( &mut self, img: LayoutSrc<'_>, page_w: f32, page_h: f32, ) -> Result<Option<Vec<Region>>, String>
Re-run one page through the fp32 graph — the escape hatch for a page
whose int8 detections look implausible (see fp32_path). Ok(None)
when there is nothing to escalate to: fp32 already loaded, an explicit
model override, or no fp32 file on disk.
Sourcepub fn predict(
&mut self,
img: LayoutSrc<'_>,
page_w: f32,
page_h: f32,
) -> Result<Vec<Region>, String>
pub fn predict( &mut self, img: LayoutSrc<'_>, page_w: f32, page_h: f32, ) -> Result<Vec<Region>, String>
Detect layout regions on a page image. page_w/page_h are the page size
in points; returned boxes are in those coordinates.
Sourcepub fn predict_batch(
&mut self,
pages: &[(LayoutSrc<'_>, f32, f32)],
) -> Result<Vec<Vec<Region>>, String>
pub fn predict_batch( &mut self, pages: &[(LayoutSrc<'_>, f32, f32)], ) -> Result<Vec<Vec<Region>>, String>
Detect layout regions on several page images with one inference call
(issue #73). The ONNX export has a dynamic batch dimension, so a worker
can amortize the per-run framework overhead and keep its cores busier on
multi-page documents. Results are per-image, index-aligned with pages,
and identical to calling predict per page.
Auto Trait Implementations§
impl !RefUnwindSafe for LayoutModel
impl !UnwindSafe for LayoutModel
impl Forget for LayoutModel
impl Freeze for LayoutModelwhere
*const ArcInner<SharedSessionInner> is !null: Freeze,
PhantomData<ArcInner<SharedSessionInner>>: Freeze,
*const u8 is !null: Freeze,
PhantomData<Outlet>: Freeze,
PhantomData<u8>: Freeze,
impl Move for LayoutModel
impl Send for LayoutModel
impl Sync for LayoutModel
impl Unpin for LayoutModel
impl UnsafeUnpin for LayoutModelwhere
*const ArcInner<SharedSessionInner> is !null: UnsafeUnpin,
PhantomData<ArcInner<SharedSessionInner>>: UnsafeUnpin,
*const u8 is !null: UnsafeUnpin,
PhantomData<Outlet>: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> ErasedDestructor for Twhere
T: 'static,
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> ⓘ
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> ⓘ
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 more