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:
@@ -71,10 +71,10 @@ export default function OcrOverlayPage() {
|
|||||||
setSteps(
|
setSteps(
|
||||||
PADDLE_DIRECT_STEPS.map((s, i) => ({
|
PADDLE_DIRECT_STEPS.map((s, i) => ({
|
||||||
...s,
|
...s,
|
||||||
status: i < 1 ? 'completed' : i === 1 ? 'active' : 'pending',
|
status: i < 4 ? 'completed' : i === 4 ? 'active' : 'pending',
|
||||||
})),
|
})),
|
||||||
)
|
)
|
||||||
setCurrentStep(1)
|
setCurrentStep(4)
|
||||||
} else {
|
} else {
|
||||||
setMode('pipeline')
|
setMode('pipeline')
|
||||||
// Map DB step to overlay UI step
|
// Map DB step to overlay UI step
|
||||||
@@ -231,6 +231,12 @@ export default function OcrOverlayPage() {
|
|||||||
case 0:
|
case 0:
|
||||||
return <StepOrientation sessionId={sessionId} onNext={handleOrientationComplete} />
|
return <StepOrientation sessionId={sessionId} onNext={handleOrientationComplete} />
|
||||||
case 1:
|
case 1:
|
||||||
|
return <StepDeskew sessionId={sessionId} onNext={handleNext} />
|
||||||
|
case 2:
|
||||||
|
return <StepDewarp sessionId={sessionId} onNext={handleNext} />
|
||||||
|
case 3:
|
||||||
|
return <StepCrop sessionId={sessionId} onNext={handleNext} />
|
||||||
|
case 4:
|
||||||
return <PaddleDirectStep sessionId={sessionId} onNext={handleNext} />
|
return <PaddleDirectStep sessionId={sessionId} onNext={handleNext} />
|
||||||
default:
|
default:
|
||||||
return null
|
return null
|
||||||
@@ -472,7 +478,7 @@ export default function OcrOverlayPage() {
|
|||||||
: 'text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300'
|
: 'text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300'
|
||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
Paddle Direct (2 Schritte)
|
Paddle Direct (5 Schritte)
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -49,11 +49,14 @@ export const OVERLAY_UI_TO_DB: Record<number, number> = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 2-step pipeline for Paddle Direct mode.
|
* 5-step pipeline for Paddle Direct mode.
|
||||||
* Upload → PaddleOCR+Overlay (skips deskew/dewarp/crop/rows)
|
* Same preprocessing (orient/deskew/dewarp/crop), then PaddleOCR replaces rows+words+overlay.
|
||||||
*/
|
*/
|
||||||
export const PADDLE_DIRECT_STEPS: PipelineStep[] = [
|
export const PADDLE_DIRECT_STEPS: PipelineStep[] = [
|
||||||
{ id: 'orientation', name: 'Upload', icon: '📤', status: 'pending' },
|
{ id: 'orientation', name: 'Orientierung', icon: '🔄', status: 'pending' },
|
||||||
|
{ id: 'deskew', name: 'Begradigung', icon: '📐', status: 'pending' },
|
||||||
|
{ id: 'dewarp', name: 'Entzerrung', icon: '🔧', status: 'pending' },
|
||||||
|
{ id: 'crop', name: 'Zuschneiden', icon: '✂️', status: 'pending' },
|
||||||
{ id: 'paddle-direct', name: 'PaddleOCR + Overlay', icon: '⚡', status: 'pending' },
|
{ id: 'paddle-direct', name: 'PaddleOCR + Overlay', icon: '⚡', status: 'pending' },
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
@@ -2511,17 +2511,23 @@ async def _word_stream_generator(
|
|||||||
|
|
||||||
@router.post("/sessions/{session_id}/paddle-direct")
|
@router.post("/sessions/{session_id}/paddle-direct")
|
||||||
async def paddle_direct(session_id: str):
|
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.
|
Expects orientation/deskew/dewarp/crop to be done already.
|
||||||
The original image is stored as cropped_png so OverlayReconstruction
|
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.
|
can display it as the background.
|
||||||
"""
|
"""
|
||||||
original_png = await get_session_image(session_id, "original")
|
# Try preprocessed images first (crop > dewarp > original)
|
||||||
if not original_png:
|
img_png = await get_session_image(session_id, "cropped")
|
||||||
raise HTTPException(status_code=404, detail="No original image found for this session")
|
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)
|
img_bgr = cv2.imdecode(img_arr, cv2.IMREAD_COLOR)
|
||||||
if img_bgr is None:
|
if img_bgr is None:
|
||||||
raise HTTPException(status_code=400, detail="Failed to decode original image")
|
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(
|
await update_session_db(
|
||||||
session_id,
|
session_id,
|
||||||
word_result=word_result,
|
word_result=word_result,
|
||||||
cropped_png=original_png,
|
cropped_png=img_png,
|
||||||
current_step=8,
|
current_step=8,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user