Suya OCR API — vLLM-backed, OpenAI-compatible OCR service
FastAPI service wrapping the Surya-OCR-2 model (datalab-to) served through vLLM: legacy /v1/api/ai/* endpoints, an OpenAI-compatible /v1/chat/completions endpoint, a coalescing request batcher, a local OCR CLI, Docker packaging, multilingual example outputs, and quantization/concurrency benchmarks. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
from typing import Dict
|
||||
|
||||
import torch
|
||||
|
||||
from surya.common.predictor import BasePredictor
|
||||
from surya.detection import DetectionPredictor
|
||||
from surya.layout import LayoutPredictor
|
||||
from surya.logging import configure_logging
|
||||
from surya.ocr_error import OCRErrorPredictor
|
||||
from surya.recognition import RecognitionPredictor
|
||||
from surya.table_rec import TableRecPredictor
|
||||
|
||||
configure_logging()
|
||||
|
||||
|
||||
def load_predictors(
|
||||
device: str | torch.device | None = None, dtype: torch.dtype | str | None = None
|
||||
) -> Dict[str, BasePredictor]:
|
||||
return {
|
||||
"layout": LayoutPredictor(device=device, dtype=dtype),
|
||||
"ocr_error": OCRErrorPredictor(device=device, dtype=dtype),
|
||||
"recognition": RecognitionPredictor(device=device, dtype=dtype),
|
||||
"detection": DetectionPredictor(device=device, dtype=dtype),
|
||||
"table_rec": TableRecPredictor(device=device, dtype=dtype),
|
||||
}
|
||||
Reference in New Issue
Block a user