EasyOCR¶
EasyOCR extractor.
EasyOCR is a PyTorch-based OCR engine with excellent multi-language support. - GPU accelerated (optional) - Supports 80+ languages - Good for scene text and printed documents
Python Package
pip install easyocr
Model Download Location
By default, EasyOCR downloads models to ~/.EasyOCR/ Can be overridden with model_storage_directory parameter
EasyOCRConfig
¶
EasyOCR
¶
Bases: BaseOCRExtractor
EasyOCR text extractor.
Single-backend model (PyTorch - CPU/GPU).
Example
Initialize EasyOCR extractor.
| PARAMETER | DESCRIPTION |
|---|---|
config
|
Configuration object
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ImportError
|
If easyocr is not installed |
Source code in omnidocs/tasks/ocr_extraction/easyocr.py
extract
¶
extract(
image: Union[Image, ndarray, str, Path],
detail: int = 1,
paragraph: bool = False,
min_size: int = 10,
text_threshold: float = 0.7,
low_text: float = 0.4,
link_threshold: float = 0.4,
canvas_size: int = 2560,
mag_ratio: float = 1.0,
) -> OCROutput
Run OCR on an image.
| PARAMETER | DESCRIPTION |
|---|---|
image
|
Input image (PIL Image, numpy array, or path)
TYPE:
|
detail
|
0 = simple output, 1 = detailed with boxes
TYPE:
|
paragraph
|
Combine results into paragraphs
TYPE:
|
min_size
|
Minimum text box size
TYPE:
|
text_threshold
|
Text confidence threshold
TYPE:
|
low_text
|
Low text bound
TYPE:
|
link_threshold
|
Link threshold for text joining
TYPE:
|
canvas_size
|
Max image dimension for processing
TYPE:
|
mag_ratio
|
Magnification ratio
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
OCROutput
|
OCROutput with detected text blocks |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If detail is not 0 or 1 |
RuntimeError
|
If EasyOCR is not initialized |
Source code in omnidocs/tasks/ocr_extraction/easyocr.py
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 | |
extract_batch
¶
Run OCR on multiple images.
| PARAMETER | DESCRIPTION |
|---|---|
images
|
List of input images
TYPE:
|
**kwargs
|
Arguments passed to extract()
DEFAULT:
|
| RETURNS | DESCRIPTION |
|---|---|
List[OCROutput]
|
List of OCROutput objects |