Skip to content
Merged

done! #344

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
10 changes: 8 additions & 2 deletions extract_thinker/document_loader/document_loader_easy_ocr.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
from cachetools import cachedmethod, TTLCache
from cachetools.keys import hashkey
from operator import attrgetter
import easyocr
import json

from extract_thinker.document_loader.cached_document_loader import CachedDocumentLoader
from extract_thinker.utils import is_pdf_stream
Expand Down Expand Up @@ -40,6 +38,14 @@ def __post_init__(self):
if self.cache_ttl <= 0:
raise ValueError("cache_ttl must be positive.")

try:
import easyocr
except ImportError:
raise ImportError(
"The 'easyocr' package is required for this loader but is not installed. "
"Please install it with: pip install easyocr"
)

self.reader = easyocr.Reader(
lang_list=self.lang_list,
gpu=self.gpu,
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ tiktoken = {version = ">=0.8.0", python = ">=3.9,<3.13"}
python-magic = ">=0.4.27"
playwright = ">=1.52.0"
libmagic = "*"
easyocr = "^1.7.1"

[tool.poetry.group.dev.dependencies]
flake8 = "^7.1.2"
Expand Down
Loading