/tesseract & /tesstrain 추가

This commit is contained in:
kyy
2025-09-09 16:23:09 +09:00
parent 7ebd979521
commit 87d0200a34
4 changed files with 103 additions and 4 deletions

View File

@@ -8,9 +8,11 @@ from config.setting import MINIO_BUCKET_NAME
from fastapi import APIRouter, File, HTTPException, UploadFile
from fastapi.responses import JSONResponse
from tasks import (
call_paddle_ocr,
call_tesseract_ocr,
call_tesstrain_ocr,
call_upstage_ocr_api,
celery_app,
parse_ocr_text,
store_ocr_result,
)
from utils.checking_keys import create_key
@@ -73,7 +75,7 @@ async def _process_ocr_request(file: UploadFile, ocr_task):
@router.post("/paddle", summary="[Paddle] 파일 업로드 기반 비동기 OCR")
async def ocr_paddle_endpoint(file: UploadFile = File(...)):
return await _process_ocr_request(file, parse_ocr_text)
return await _process_ocr_request(file, call_paddle_ocr)
@router.post("/upstage", summary="[Upstage] 파일 업로드 기반 비동기 OCR")
@@ -81,6 +83,16 @@ async def ocr_upstage_endpoint(file: UploadFile = File(...)):
return await _process_ocr_request(file, call_upstage_ocr_api)
@router.post("/tesseract", summary="[Tesseract] 기본 모델 비동기 OCR")
async def ocr_tesseract_endpoint(file: UploadFile = File(...)):
return await _process_ocr_request(file, call_tesseract_ocr)
@router.post("/tesstrain", summary="[Tesseract] 훈련된 모델 비동기 OCR")
async def ocr_tesstrain_endpoint(file: UploadFile = File(...)):
return await _process_ocr_request(file, call_tesstrain_ocr)
@router.get("/progress/{request_id}", summary="OCR 진행 상태 및 결과 조회")
async def check_progress(request_id: str):
task_id = redis_client.hget("ocr_task_mapping", request_id)