mirror of
https://github.com/immich-app/immich
synced 2025-10-17 18:19:27 +00:00
28 lines
785 B
Python
28 lines
785 B
Python
from typing import Iterable
|
|
|
|
import numpy as np
|
|
import numpy.typing as npt
|
|
from rapidocr.utils.typings import EngineType, LangRec
|
|
from typing_extensions import TypedDict
|
|
|
|
|
|
class TextDetectionOutput(TypedDict):
|
|
image: npt.NDArray[np.float32]
|
|
boxes: npt.NDArray[np.float32]
|
|
scores: npt.NDArray[np.float32]
|
|
|
|
|
|
class TextRecognitionOutput(TypedDict):
|
|
box: npt.NDArray[np.float32]
|
|
boxScore: npt.NDArray[np.float32]
|
|
text: Iterable[str]
|
|
textScore: npt.NDArray[np.float32]
|
|
|
|
|
|
# RapidOCR expects `engine_type`, `lang_type`, and `font_path` to be attributes
|
|
class OcrOptions(dict):
|
|
def __init__(self, **options):
|
|
super().__init__(**options)
|
|
self.engine_type = EngineType.ONNXRUNTIME
|
|
self.lang_type = LangRec.CH
|
|
self.font_path = None
|