DocBank<T>
Models & Types · AiDotNet.Document.Analysis.PageSegmentation
DocBank model for document page segmentation and layout analysis.
Inheritance: NeuralNetworkBase<T> → DocumentNeuralNetworkBase<T> → DocBank<T>
Implements: IPageSegmenter<T>
For Beginners
DocBank divides document pages into different regions:
- Paragraphs: Regular text content
- Titles: Document headings and titles
- Figures: Images and diagrams
- Tables: Tabular data regions
- Captions: Text describing figures/tables
- Lists: Bulleted or numbered lists
- Equations: Mathematical formulas
- And more…
Example usage:
How It Works
DocBank is a benchmark and model for document layout analysis that can segment document pages into semantic regions including text, titles, figures, tables, and captions. It combines visual features with optional text features for robust segmentation.
Reference: “DocBank: A Benchmark Dataset for Document Layout Analysis” (COLING 2020)
https://arxiv.org/abs/2006.01038
Constructors
| Constructor | Summary |
|---|---|
DocBank(NeuralNetworkArchitecture<T> architecture, IGradientBasedOptimizer<T, Tensor<T>, Tensor<T>> optimizer, ILossFunction<T> lossFunction, DocBankOptions options) |
Creates a DocBank model using native layers for training and inference. |
DocBank(NeuralNetworkArchitecture<T> architecture, string onnxModelPath, IGradientBasedOptimizer<T, Tensor<T>, Tensor<T>> optimizer, ILossFunction<T> lossFunction, DocBankOptions options) |
Creates a DocBank model using a pre-trained ONNX model for inference. |
Properties
| Property | Summary |
|---|---|
DocumentType SupportedDocumentTypes { get; } |
|
IReadOnlyList<DocumentRegionType> SupportedRegionTypes { get; } |
|
IReadOnlyList<DocumentRegionType> TokenLabels { get; } |
DocBank’s twelve token labels (Li et al. |
LayoutLM<T> TokenClassifier { get; } |
The paper’s baseline (Li et al. |
bool RequiresOCR { get; } |
|
bool SupportsInstanceSegmentation { get; } |
|
int ExpectedImageSize { get; } |
|
int NumClasses { get; } |
Gets the number of segmentation classes. |
Methods
| Method | Summary |
|---|---|
IReadOnlyList<ValueTuple<DocumentRegionType, T>> ClassifyTokens(Tensor<T> packedTokens) |
Labels each token of a page as DocBank’s baselines do: packedTokens is [seq, 5] rows of (tokenId, x0, y0, x1, y1) with boxes on LayoutLM’s 0-1000 grid; each token gets the softmax argmax of the TokenClassifier and that probability. |
ModelMetadata<T> GetModelMetadata() |
|
PageSegmentationResult<T> SegmentPage(Tensor<T> documentImage) |
|
PageSegmentationResult<T> SegmentPage(Tensor<T> documentImage, double confidenceThreshold) |
|
Tensor<T> EncodeDocument(Tensor<T> documentImage) |
|
Tensor<T> ForwardForTraining(Tensor<T> input) |
Training forward — the same direct backbone pass as inference (tape-aware). |
Tensor<T> GetSegmentationMask(Tensor<T> documentImage) |
|
string GetModelSummary() |
|
void ValidateInputShape(Tensor<T> documentImage) |