Skip to content

Commit

Permalink
Updated imports with try-except
Browse files Browse the repository at this point in the history
  • Loading branch information
ajkdrag committed Mar 14, 2024
1 parent aea6f2f commit ce45e69
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/ocrtoolkit/integrations/paddleocr.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,16 @@
import importlib_resources
import numpy as np
from loguru import logger
from paddleocr.tools.infer import utility
from ppocr import utils as pputils

try:
from paddleocr.tools.infer import utility
from ppocr import utils as pputils

EN_DICT_FILE = importlib_resources.files(pputils).joinpath("en_dict.txt").as_posix()
except ImportError:
EN_DICT_FILE = None
logger.warning("PaddleOCR not installed")


from ocrtoolkit.utilities.network_utils import download_file
from ocrtoolkit.wrappers.bbox import BBox
Expand All @@ -17,7 +25,6 @@
"DB": f"{BASE_URL}/PP-OCRv3/english/en_PP-OCRv3_det_infer.tar",
"SVTR_LCNet": f"{BASE_URL}/PP-OCRv4/english/en_PP-OCRv4_rec_infer.tar",
}
EN_DICT_FILE = importlib_resources.files(pputils).joinpath("en_dict.txt").as_posix()


class PaddleOCRDetModel(DetectionModel):
Expand Down

0 comments on commit ce45e69

Please sign in to comment.