This commit is contained in:
18
docs/snippets/python/ocr/ocr_easyocr.md
Normal file
18
docs/snippets/python/ocr/ocr_easyocr.md
Normal file
@@ -0,0 +1,18 @@
|
||||
```python title="Python"
|
||||
from kreuzberg import extract_file_sync, ExtractionConfig, OcrConfig
|
||||
|
||||
config: ExtractionConfig = ExtractionConfig(
|
||||
ocr=OcrConfig(backend="easyocr", language="en")
|
||||
)
|
||||
|
||||
# EasyOCR-specific options (use_gpu, beam_width, etc.) go in easyocr_kwargs,
|
||||
# not in OcrConfig — OcrConfig only accepts backend, language, and backend-specific configs.
|
||||
result = extract_file_sync("scanned.pdf", config=config, easyocr_kwargs={"use_gpu": True})
|
||||
|
||||
content: str = result.content
|
||||
preview: str = content[:100]
|
||||
total_length: int = len(content)
|
||||
|
||||
print(f"Extracted content (preview): {preview}")
|
||||
print(f"Total characters: {total_length}")
|
||||
```
|
||||
Reference in New Issue
Block a user