feat(ocr): enhance OCR model configuration with orientation classification and unwarping options, update PaddleOCR integration, and improve response structure

This commit is contained in:
CoderKang 2025-06-02 20:40:32 +08:00 committed by mertalev
parent 3949bf2cfa
commit 0e7ad8b2ba
No known key found for this signature in database
GPG key ID: DF6ABC77AAD98C95
15 changed files with 135 additions and 123 deletions

View file

@ -38,7 +38,13 @@ class ModelCache:
async def get(
self, model_name: str, model_type: ModelType, model_task: ModelTask, **model_kwargs: Any
) -> InferenceModel:
key = f"{model_name}{model_type}{model_task}"
config_key = ""
if model_type == ModelType.OCR and model_task == ModelTask.OCR:
orientation = model_kwargs.get("orientationClassifyEnabled", True)
unwarping = model_kwargs.get("unwarpingEnabled", True)
config_key = f"_o{orientation}_u{unwarping}"
key = f"{model_name}{model_type}{model_task}{config_key}"
async with OptimisticLock(self.cache, key) as lock:
model: InferenceModel | None = await self.cache.get(key)