Files
Fu DaiandClaude Opus 4.8 1a585693be 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>
2026-06-17 10:20:02 +04:00

49 lines
1.1 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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