Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding EffOCR support within the layout parser #189

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
133 changes: 0 additions & 133 deletions README.md

This file was deleted.

70 changes: 0 additions & 70 deletions installation.md

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
is_effdet_available,
is_pytesseract_available,
is_gcv_available,
is_effocr_available,
)

_import_structure = {
Expand Down Expand Up @@ -51,6 +52,7 @@
"is_paddle_available",
"is_pytesseract_available",
"is_gcv_available",
"is_effocr_available",
"requires_backends"
],
"tools": [
Expand Down Expand Up @@ -80,6 +82,9 @@
if is_gcv_available():
_import_structure["ocr.gcv_agent"] = ["GCVAgent", "GCVFeatureType"]

if is_effocr_available():
_import_structure["ocr.effocr_agent"] = ["EffOCRAgent", "EffOCRFeatureType"]

sys.modules[__name__] = _LazyModule(
__name__,
globals()["__file__"],
Expand Down
File renamed without changes.
File renamed without changes.
19 changes: 19 additions & 0 deletions src/layoutparser/file_utils.py → src/effocr-layout/file_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,14 @@
except ModuleNotFoundError:
_gcv_available = False

try:
_effocr_available = importlib.util.find_spec("onnxruntime") is not None \
and importlib.util.find_spec("onnx") is not None \
and importlib.util.find_spec("faiss") is not None
except ModuleNotFoundError:
_effocr_available = False



def is_torch_available():
return _torch_available
Expand Down Expand Up @@ -121,6 +129,9 @@ def is_pytesseract_available():
def is_gcv_available():
return _gcv_available

def is_effocr_available():
return _effocr_available


PYTORCH_IMPORT_ERROR = """
{0} requires the PyTorch library but it was not found in your environment. Checkout the instructions on the
Expand Down Expand Up @@ -154,6 +165,13 @@ def is_gcv_available():
`pip install google-cloud-vision==1`
"""

EFFOCR_IMPORT_ERROR = """
{0} requires the onnxruntime, onnx and faiss libraries but at least one was not found in your environment. You can install it with pip:
`pip install onnxruntime onnx faiss`
Note that `faiss` can be installed with eiter the CPU or GPU version, but the GPU version requires CUDA. See
https://github.com/facebookresearch/faiss/blob/main/INSTALL.md for more details.
"""

BACKENDS_MAPPING = dict(
[
("torch", (is_torch_available, PYTORCH_IMPORT_ERROR)),
Expand All @@ -162,6 +180,7 @@ def is_gcv_available():
("effdet", (is_effdet_available, EFFDET_IMPORT_ERROR)),
("pytesseract", (is_pytesseract_available, PYTESSERACT_IMPORT_ERROR)),
("google-cloud-vision", (is_gcv_available, GCV_IMPORT_ERROR)),
("effocr", (is_effocr_available, EFFOCR_IMPORT_ERROR))
]
)

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@
# limitations under the License.

from .gcv_agent import GCVAgent, GCVFeatureType
from .tesseract_agent import TesseractAgent, TesseractFeatureType
from .tesseract_agent import TesseractAgent, TesseractFeatureType
from .effocr_agent import EffOCRAgent, EffOCRFeatureType
File renamed without changes.
3 changes: 3 additions & 0 deletions src/effocr-layout/ocr/effocr/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from .engines import EffLineDetector, EffLocalizer, EffRecognizer
from .utils import create_paired_transform, create_paired_transform_word, letterbox, non_max_suppression
from .infer_transcripton import run_effocr_word
3 changes: 3 additions & 0 deletions src/effocr-layout/ocr/effocr/engines/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from .localizer_engine import EffLocalizer
from .recognizer_engine import EffRecognizer
from .line_det_engine import EffLineDetector
Loading