mirror of
https://github.com/DS4SD/docling.git
synced 2025-07-30 14:04:27 +00:00
28 lines
872 B
Python
28 lines
872 B
Python
import logging
|
|
from functools import lru_cache
|
|
|
|
from docling.models.factories.ocr_factory import OcrFactory
|
|
from docling.models.factories.picture_description_factory import (
|
|
PictureDescriptionFactory,
|
|
)
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
@lru_cache()
|
|
def get_ocr_factory(allow_external_plugins: bool = False) -> OcrFactory:
|
|
factory = OcrFactory()
|
|
factory.load_from_plugins(allow_external_plugins=allow_external_plugins)
|
|
logger.info("Registered ocr engines: %r", factory.registered_kind)
|
|
return factory
|
|
|
|
|
|
@lru_cache()
|
|
def get_picture_description_factory(
|
|
allow_external_plugins: bool = False,
|
|
) -> PictureDescriptionFactory:
|
|
factory = PictureDescriptionFactory()
|
|
factory.load_from_plugins(allow_external_plugins=allow_external_plugins)
|
|
logger.info("Registered picture descriptions: %r", factory.registered_kind)
|
|
return factory
|