fix: Paddle Direct keeps preprocessing (orient/deskew/dewarp/crop)
Some checks failed
CI / nodejs-lint (push) Has been cancelled
CI / go-lint (push) Has been cancelled
CI / python-lint (push) Has been cancelled
CI / test-go-school (push) Has been cancelled
CI / test-go-edu-search (push) Has been cancelled
CI / test-python-klausur (push) Has been cancelled
CI / test-python-agent-core (push) Has been cancelled
CI / test-nodejs-website (push) Has been cancelled
Some checks failed
CI / nodejs-lint (push) Has been cancelled
CI / go-lint (push) Has been cancelled
CI / python-lint (push) Has been cancelled
CI / test-go-school (push) Has been cancelled
CI / test-go-edu-search (push) Has been cancelled
CI / test-python-klausur (push) Has been cancelled
CI / test-python-agent-core (push) Has been cancelled
CI / test-nodejs-website (push) Has been cancelled
Uses the cropped/dewarped image instead of the original so the overlay shows the correctly oriented page. 5 steps instead of 2. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -2511,17 +2511,23 @@ async def _word_stream_generator(
|
||||
|
||||
@router.post("/sessions/{session_id}/paddle-direct")
|
||||
async def paddle_direct(session_id: str):
|
||||
"""Run PaddleOCR on the original image and build a word grid directly.
|
||||
"""Run PaddleOCR on the preprocessed image and build a word grid directly.
|
||||
|
||||
Skips deskew/dewarp/crop/rows — just Upload → PaddleOCR → Overlay.
|
||||
The original image is stored as cropped_png so OverlayReconstruction
|
||||
Expects orientation/deskew/dewarp/crop to be done already.
|
||||
Uses the cropped image (falls back to dewarped, then original).
|
||||
The used image is stored as cropped_png so OverlayReconstruction
|
||||
can display it as the background.
|
||||
"""
|
||||
original_png = await get_session_image(session_id, "original")
|
||||
if not original_png:
|
||||
raise HTTPException(status_code=404, detail="No original image found for this session")
|
||||
# Try preprocessed images first (crop > dewarp > original)
|
||||
img_png = await get_session_image(session_id, "cropped")
|
||||
if not img_png:
|
||||
img_png = await get_session_image(session_id, "dewarped")
|
||||
if not img_png:
|
||||
img_png = await get_session_image(session_id, "original")
|
||||
if not img_png:
|
||||
raise HTTPException(status_code=404, detail="No image found for this session")
|
||||
|
||||
img_arr = np.frombuffer(original_png, dtype=np.uint8)
|
||||
img_arr = np.frombuffer(img_png, dtype=np.uint8)
|
||||
img_bgr = cv2.imdecode(img_arr, cv2.IMREAD_COLOR)
|
||||
if img_bgr is None:
|
||||
raise HTTPException(status_code=400, detail="Failed to decode original image")
|
||||
@@ -2562,11 +2568,11 @@ async def paddle_direct(session_id: str):
|
||||
},
|
||||
}
|
||||
|
||||
# Store original image as cropped_png so OverlayReconstruction shows it
|
||||
# Store preprocessed image as cropped_png so OverlayReconstruction shows it
|
||||
await update_session_db(
|
||||
session_id,
|
||||
word_result=word_result,
|
||||
cropped_png=original_png,
|
||||
cropped_png=img_png,
|
||||
current_step=8,
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user