From 3aa4a632579ad595b70383a3f07879f199d570bc Mon Sep 17 00:00:00 2001 From: Benjamin Admin Date: Mon, 16 Mar 2026 13:38:58 +0100 Subject: [PATCH] fix: move Struktur step after OCR so word boxes are available for exclusion MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Graphic detection needs word positions to exclude text from the ink mask. Previously Struktur ran before OCR, causing every word to be detected as a graphic element. Now: - Pipeline: Struktur at index 7 (after WΓΆrter) - Kombi: Struktur at index 5 (after PP-OCRv5+Tesseract, before Tabelle) Co-Authored-By: Claude Opus 4.6 --- .../app/(admin)/ai/ocr-overlay/page.tsx | 34 ++++++++++--------- .../app/(admin)/ai/ocr-overlay/types.ts | 2 +- .../app/(admin)/ai/ocr-pipeline/page.tsx | 24 ++++++------- .../app/(admin)/ai/ocr-pipeline/types.ts | 2 +- 4 files changed, 32 insertions(+), 30 deletions(-) diff --git a/admin-lehrer/app/(admin)/ai/ocr-overlay/page.tsx b/admin-lehrer/app/(admin)/ai/ocr-overlay/page.tsx index 3f149da..8e03dbe 100644 --- a/admin-lehrer/app/(admin)/ai/ocr-overlay/page.tsx +++ b/admin-lehrer/app/(admin)/ai/ocr-overlay/page.tsx @@ -76,12 +76,12 @@ export default function OcrOverlayPage() { setMode(m) // For Kombi: if grid_editor_result exists, jump to grid editor step (6) - // If word_result exists but no grid, jump to grid editor (6) - // If structure_result exists, jump to kombi step (5) + // If structure_result exists, jump to grid editor (6) + // If word_result exists, jump to structure step (5) const hasGrid = isKombi && data.grid_editor_result - const hasWords = isKombi && data.word_result const hasStructure = isKombi && data.structure_result - const activeStep = hasGrid ? 6 : hasWords ? 6 : hasStructure ? 5 : 4 + const hasWords = isKombi && data.word_result + const activeStep = hasGrid ? 6 : hasStructure ? 6 : hasWords ? 5 : 4 setSteps( baseSteps.map((s, i) => ({ ...s, @@ -252,22 +252,24 @@ export default function OcrOverlayPage() { return case 4: if (mode === 'kombi') { - return + return ( + + ) } return case 5: return mode === 'kombi' ? ( - + ) : null case 6: return mode === 'kombi' ? ( diff --git a/admin-lehrer/app/(admin)/ai/ocr-overlay/types.ts b/admin-lehrer/app/(admin)/ai/ocr-overlay/types.ts index f635924..fb45719 100644 --- a/admin-lehrer/app/(admin)/ai/ocr-overlay/types.ts +++ b/admin-lehrer/app/(admin)/ai/ocr-overlay/types.ts @@ -69,8 +69,8 @@ export const KOMBI_STEPS: PipelineStep[] = [ { id: 'deskew', name: 'Begradigung', icon: 'πŸ“', status: 'pending' }, { id: 'dewarp', name: 'Entzerrung', icon: 'πŸ”§', status: 'pending' }, { id: 'crop', name: 'Zuschneiden', icon: 'βœ‚οΈ', status: 'pending' }, - { id: 'structure', name: 'Struktur', icon: 'πŸ”', status: 'pending' }, { id: 'kombi', name: 'PP-OCRv5 + Tesseract', icon: 'πŸ”€', status: 'pending' }, + { id: 'structure', name: 'Struktur', icon: 'πŸ”', status: 'pending' }, { id: 'grid-editor', name: 'Tabelle', icon: 'πŸ“Š', status: 'pending' }, ] diff --git a/admin-lehrer/app/(admin)/ai/ocr-pipeline/page.tsx b/admin-lehrer/app/(admin)/ai/ocr-pipeline/page.tsx index 5a39d01..378159b 100644 --- a/admin-lehrer/app/(admin)/ai/ocr-pipeline/page.tsx +++ b/admin-lehrer/app/(admin)/ai/ocr-pipeline/page.tsx @@ -92,15 +92,15 @@ export default function OcrPipelinePage() { let uiStep = Math.max(0, dbStep - 1) const skipSteps = [...(savedDocType?.skip_steps || [])] - // Sub-sessions: image is already cropped, skip pre-processing + structure steps - // Jump directly to columns (UI step 5) unless already further ahead + // Sub-sessions: image is already cropped, skip pre-processing steps + // Jump directly to columns (UI step 4) unless already further ahead const isSubSession = !!data.parent_session_id - const SUB_SESSION_SKIP = ['orientation', 'deskew', 'dewarp', 'crop', 'structure'] + const SUB_SESSION_SKIP = ['orientation', 'deskew', 'dewarp', 'crop'] if (isSubSession) { for (const s of SUB_SESSION_SKIP) { if (!skipSteps.includes(s)) skipSteps.push(s) } - if (uiStep < 5) uiStep = 5 // columns step (now index 5) + if (uiStep < 4) uiStep = 4 // columns step (index 4) } setSteps( @@ -330,10 +330,10 @@ export default function OcrPipelinePage() { 2: 'Begradigung', 3: 'Entzerrung', 4: 'Zuschneiden', - 5: 'Struktur', - 6: 'Spalten', - 7: 'Zeilen', - 8: 'Woerter', + 5: 'Spalten', + 6: 'Zeilen', + 7: 'Woerter', + 8: 'Struktur', 9: 'Korrektur', 10: 'Rekonstruktion', 11: 'Validierung', @@ -373,13 +373,13 @@ export default function OcrPipelinePage() { case 3: return case 4: - return - case 5: return - case 6: + case 5: return - case 7: + case 6: return + case 7: + return case 8: return case 9: diff --git a/admin-lehrer/app/(admin)/ai/ocr-pipeline/types.ts b/admin-lehrer/app/(admin)/ai/ocr-pipeline/types.ts index 60d4bb1..2a205cd 100644 --- a/admin-lehrer/app/(admin)/ai/ocr-pipeline/types.ts +++ b/admin-lehrer/app/(admin)/ai/ocr-pipeline/types.ts @@ -392,10 +392,10 @@ export const PIPELINE_STEPS: PipelineStep[] = [ { id: 'deskew', name: 'Begradigung', icon: 'πŸ“', status: 'pending' }, { id: 'dewarp', name: 'Entzerrung', icon: 'πŸ”§', status: 'pending' }, { id: 'crop', name: 'Zuschneiden', icon: 'βœ‚οΈ', status: 'pending' }, - { id: 'structure', name: 'Struktur', icon: 'πŸ”', status: 'pending' }, { id: 'columns', name: 'Spalten', icon: 'πŸ“Š', status: 'pending' }, { id: 'rows', name: 'Zeilen', icon: 'πŸ“', status: 'pending' }, { id: 'words', name: 'Woerter', icon: 'πŸ”€', status: 'pending' }, + { id: 'structure', name: 'Struktur', icon: 'πŸ”', status: 'pending' }, { id: 'llm-review', name: 'Korrektur', icon: '✏️', status: 'pending' }, { id: 'reconstruction', name: 'Rekonstruktion', icon: 'πŸ—οΈ', status: 'pending' }, { id: 'ground-truth', name: 'Validierung', icon: 'βœ…', status: 'pending' },