-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
561 additions
and
354 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
name: Integration test with benchmark | ||
|
||
on: [push] | ||
on: [] # re-enable after integration | ||
|
||
env: | ||
TORCH_DEVICE: "cpu" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: CI tests | ||
|
||
on: [push] | ||
|
||
env: | ||
TORCH_DEVICE: "cpu" | ||
OCR_ENGINE: "surya" | ||
|
||
jobs: | ||
tests: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python 3.11 | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: 3.11 | ||
- name: Install python dependencies | ||
run: | | ||
pip install poetry | ||
poetry install | ||
- name: Run tests | ||
env: | ||
HF_TOKEN: ${{ secrets.HF_TOKEN }} | ||
run: poetry run pytest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
from typing import Dict, Type | ||
from importlib import import_module | ||
|
||
from marker.v2.schema import BlockTypes | ||
from marker.v2.schema.blocks import Block, Caption, Code, Equation, Figure, \ | ||
Footnote, Form, Handwriting, InlineMath, \ | ||
ListItem, PageFooter, PageHeader, Picture, \ | ||
SectionHeader, Table, TableOfContents, \ | ||
Text | ||
from marker.v2.schema.document import Document | ||
from marker.v2.schema.groups import FigureGroup, ListGroup, PageGroup, \ | ||
PictureGroup, TableGroup | ||
from marker.v2.schema.text import Line, Span | ||
|
||
BLOCK_REGISTRY: Dict[BlockTypes, str] = {} | ||
|
||
|
||
def register_block_class(block_type: BlockTypes, block_cls: Type[Block]): | ||
BLOCK_REGISTRY[block_type] = f"{block_cls.__module__}.{block_cls.__name__}" | ||
|
||
|
||
def get_block_class(block_type: BlockTypes) -> Type[Block]: | ||
class_path = BLOCK_REGISTRY[block_type] | ||
module_name, class_name = class_path.rsplit('.', 1) | ||
module = import_module(module_name) | ||
return getattr(module, class_name) | ||
|
||
|
||
register_block_class(BlockTypes.Line, Line) | ||
register_block_class(BlockTypes.Span, Span) | ||
register_block_class(BlockTypes.FigureGroup, FigureGroup) | ||
register_block_class(BlockTypes.TableGroup, TableGroup) | ||
register_block_class(BlockTypes.ListGroup, ListGroup) | ||
register_block_class(BlockTypes.PictureGroup, PictureGroup) | ||
register_block_class(BlockTypes.Page, PageGroup) | ||
register_block_class(BlockTypes.Caption, Caption) | ||
register_block_class(BlockTypes.Code, Code) | ||
register_block_class(BlockTypes.Figure, Figure) | ||
register_block_class(BlockTypes.Footnote, Footnote) | ||
register_block_class(BlockTypes.Form, Form) | ||
register_block_class(BlockTypes.Equation, Equation) | ||
register_block_class(BlockTypes.Handwriting, Handwriting) | ||
register_block_class(BlockTypes.TextInlineMath, InlineMath) | ||
register_block_class(BlockTypes.ListItem, ListItem) | ||
register_block_class(BlockTypes.PageFooter, PageFooter) | ||
register_block_class(BlockTypes.PageHeader, PageHeader) | ||
register_block_class(BlockTypes.Picture, Picture) | ||
register_block_class(BlockTypes.SectionHeader, SectionHeader) | ||
register_block_class(BlockTypes.Table, Table) | ||
register_block_class(BlockTypes.Text, Text) | ||
register_block_class(BlockTypes.TableOfContents, TableOfContents) | ||
register_block_class(BlockTypes.Document, Document) | ||
|
||
assert len(BLOCK_REGISTRY) == len(BlockTypes) | ||
assert all([get_block_class(k).model_fields['block_type'].default == k for k, _ in BLOCK_REGISTRY.items()]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,2 @@ | ||
from marker.v2.schema import BlockTypes | ||
from marker.v2.schema.text.line import Line | ||
from marker.v2.schema.text.span import Span | ||
|
||
TEXT_BLOCK_REGISTRY = { | ||
BlockTypes.Line: Line, | ||
BlockTypes.Span: Span, | ||
} |
Oops, something went wrong.