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,17 @@
|
||||
from typing import List
|
||||
|
||||
import pypdfium2
|
||||
|
||||
from surya.settings import settings
|
||||
|
||||
|
||||
def open_pdf(pdf_filepath):
|
||||
return pypdfium2.PdfDocument(pdf_filepath)
|
||||
|
||||
|
||||
def get_page_images(doc, indices: List, dpi=settings.IMAGE_DPI):
|
||||
images = [
|
||||
doc[i].render(scale=dpi / 72, draw_annots=False).to_pil() for i in indices
|
||||
]
|
||||
images = [image.convert("RGB") for image in images]
|
||||
return images
|
||||
Reference in New Issue
Block a user