3939 # The name of the paddlepaddle library:
4040 # Install name: pip install paddlepaddle
4141 # Import name: import paddle
42- _paddle_version = importlib_metadata .version ("paddlepaddle" )
42+ _paddle_version = importlib_metadata .version ("paddlepaddle" )
4343 logger .debug (f"Paddle version { _paddle_version } available." )
4444except importlib_metadata .PackageNotFoundError :
4545 _paddle_available = False
4646
47+ _effdet_available = importlib .util .find_spec ("effdet" ) is not None
48+ try :
49+ _effdet_version = importlib_metadata .version ("effdet" )
50+ logger .debug (f"Effdet version { _effdet_version } available." )
51+ except importlib_metadata .PackageNotFoundError :
52+ _effdet_version = False
53+
4754###########################################
4855############## OCR Tool Deps ##############
4956###########################################
@@ -78,12 +85,16 @@ def is_torch_cuda_available():
7885 return False
7986
8087
88+ def is_detectron2_available ():
89+ return _detectron2_available
90+
91+
8192def is_paddle_available ():
8293 return _paddle_available
8394
8495
85- def is_detectron2_available ():
86- return _detectron2_available
96+ def is_effdet_available ():
97+ return _effdet_available
8798
8899
89100def is_pytesseract_available ():
@@ -111,6 +122,11 @@ def is_gcv_available():
111122installation page: https://github.com/PaddlePaddle/Paddle and follow the ones that match your environment.
112123"""
113124
125+ EFFDET_IMPORT_ERROR = """
126+ {0} requires the effdet library but it was not found in your environment. You can install it with pip:
127+ `pip install effdet`
128+ """
129+
114130PYTESSERACT_IMPORT_ERROR = """
115131{0} requires the PyTesseract library but it was not found in your environment. You can install it with pip:
116132`pip install pytesseract`
@@ -126,6 +142,7 @@ def is_gcv_available():
126142 ("torch" , (is_torch_available , PYTORCH_IMPORT_ERROR )),
127143 ("detectron2" , (is_detectron2_available , DETECTRON2_IMPORT_ERROR )),
128144 ("paddle" , (is_paddle_available , PADDLE_IMPORT_ERROR )),
145+ ("effdet" , (is_effdet_available , )),
129146 ("pytesseract" , (is_pytesseract_available , PYTESSERACT_IMPORT_ERROR )),
130147 ("google-cloud-vision" , (is_gcv_available , GCV_IMPORT_ERROR )),
131148 ]
@@ -172,7 +189,7 @@ def __init__(
172189 self ._import_structure = import_structure
173190
174191 # Following [PEP 366](https://www.python.org/dev/peps/pep-0366/)
175- # The __package__ variable should be set
192+ # The __package__ variable should be set
176193 # https://docs.python.org/3/reference/import.html#__package__
177194 self .__package__ = self .__name__
178195
@@ -198,4 +215,4 @@ def _get_module(self, module_name: str):
198215 return importlib .import_module ("." + module_name , self .__name__ )
199216
200217 def __reduce__ (self ):
201- return (self .__class__ , (self ._name , self .__file__ , self ._import_structure ))
218+ return (self .__class__ , (self ._name , self .__file__ , self ._import_structure ))
0 commit comments