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,48 @@
|
||||
from typing import List, Optional
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
||||
from surya.common.polygon import PolygonBox
|
||||
|
||||
|
||||
class TableRow(PolygonBox):
|
||||
row_id: int
|
||||
|
||||
@property
|
||||
def label(self) -> str:
|
||||
return f"Row {self.row_id}"
|
||||
|
||||
|
||||
class TableCol(PolygonBox):
|
||||
col_id: int
|
||||
|
||||
@property
|
||||
def label(self) -> str:
|
||||
return f"Column {self.col_id}"
|
||||
|
||||
|
||||
class TableCell(PolygonBox):
|
||||
"""Geometric cell derived from row × column intersection.
|
||||
|
||||
The simple-path TableRecPredictor doesn't return spanning info from the
|
||||
model — colspan/rowspan/header come from the full-path HTML output if
|
||||
needed."""
|
||||
|
||||
row_id: int
|
||||
col_id: int
|
||||
cell_id: int
|
||||
|
||||
@property
|
||||
def label(self) -> str:
|
||||
return f"Cell {self.cell_id}"
|
||||
|
||||
|
||||
class TableResult(BaseModel):
|
||||
rows: List[TableRow]
|
||||
cols: List[TableCol]
|
||||
cells: List[TableCell]
|
||||
image_bbox: List[float]
|
||||
raw: Optional[str] = None # raw model output
|
||||
html: Optional[str] = None # populated when full-path was used
|
||||
mode: str = "simple" # "simple" | "full"
|
||||
error: bool = False
|
||||
Reference in New Issue
Block a user