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>
20 lines
569 B
Python
20 lines
569 B
Python
from typing import List, Optional
|
|
|
|
from pydantic import BaseModel
|
|
|
|
from surya.common.polygon import PolygonBox
|
|
|
|
|
|
class LayoutBox(PolygonBox):
|
|
label: str # canonicalized via LAYOUT_PRED_RELABEL
|
|
raw_label: str # original model label, before canonicalization
|
|
position: int # reading order index
|
|
count: int = 0 # model's token estimate for OCR output (multiple of 50)
|
|
|
|
|
|
class LayoutResult(BaseModel):
|
|
bboxes: List[LayoutBox]
|
|
image_bbox: List[float]
|
|
raw: Optional[str] = None # raw model output, useful for debugging
|
|
error: bool = False
|