feat: OCR pipeline with NDJSON streaming and real-time progress (#226, #227, #231) #229

Merged
marcel merged 74 commits from feat/issue-226-227-ocr-pipeline-polygon into main 2026-04-13 12:39:04 +02:00
2 changed files with 10 additions and 9 deletions
Showing only changes of commit 838330b405 - Show all commits

View File

@@ -56,9 +56,9 @@ async def run_ocr(request: OcrRequest):
if not _models_ready:
raise HTTPException(status_code=503, detail="Models not loaded yet")
images = await _download_and_convert_pdf(request.pdf_url)
images = await _download_and_convert_pdf(request.pdfUrl)
script_type = request.script_type.upper()
script_type = request.scriptType.upper()
if script_type == "HANDWRITING_KURRENT":
if not kraken_engine.is_available():

View File

@@ -1,20 +1,21 @@
from pydantic import BaseModel, Field
from pydantic import BaseModel, ConfigDict
class OcrRequest(BaseModel):
pdf_url: str = Field(..., alias="pdfUrl")
script_type: str = Field("UNKNOWN", alias="scriptType")
model_config = ConfigDict(populate_by_name=True)
pdfUrl: str
scriptType: str = "UNKNOWN"
language: str = "de"
class OcrBlock(BaseModel):
page_number: int = Field(..., alias="pageNumber")
model_config = ConfigDict(populate_by_name=True)
pageNumber: int
x: float
y: float
width: float
height: float
polygon: list[list[float]] | None = None
text: str
class Config:
populate_by_name = True