From eb45bb4879a867fbc017a85571f8ffeda72f0177 Mon Sep 17 00:00:00 2001 From: Benjamin Admin Date: Mon, 9 Mar 2026 08:02:44 +0100 Subject: [PATCH] fix: numpy array or-Verknuepfung in Crop/Deskew + ImageCompareView Labels - orientation_crop_api.py: `array or array` durch `is not None` ersetzt (ValueError bei numpy Arrays) - ocr_pipeline_api.py: gleicher Fix fuer Deskew-Fallback-Kette - ImageCompareView.tsx: Fallback-Text nutzt rightLabel statt "Begradigung" Co-Authored-By: Claude Opus 4.6 --- .../components/ocr-pipeline/ImageCompareView.tsx | 4 ++-- klausur-service/backend/ocr_pipeline_api.py | 6 ++++-- klausur-service/backend/orientation_crop_api.py | 9 ++++++--- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/admin-lehrer/components/ocr-pipeline/ImageCompareView.tsx b/admin-lehrer/components/ocr-pipeline/ImageCompareView.tsx index 2d448a7..9df3afa 100644 --- a/admin-lehrer/components/ocr-pipeline/ImageCompareView.tsx +++ b/admin-lehrer/components/ocr-pipeline/ImageCompareView.tsx @@ -125,7 +125,7 @@ export function ImageCompareView({ <> Begradigtes Bild setRightError(true)} /> @@ -133,7 +133,7 @@ export function ImageCompareView({ ) : (
- {rightError ? 'Fehler beim Laden' : 'Begradigung laeuft...'} + {rightError ? 'Fehler beim Laden' : `${rightLabel || 'Verarbeitung'} laeuft...`}
)} diff --git a/klausur-service/backend/ocr_pipeline_api.py b/klausur-service/backend/ocr_pipeline_api.py index 4fc55be..271bfc5 100644 --- a/klausur-service/backend/ocr_pipeline_api.py +++ b/klausur-service/backend/ocr_pipeline_api.py @@ -484,7 +484,8 @@ async def auto_deskew(session_id: str): cached = _get_cached(session_id) # Use cropped image as input (from step 2), fall back to oriented, then original - img_bgr = cached.get("cropped_bgr") or cached.get("oriented_bgr") or cached.get("original_bgr") + img_bgr = next((v for k in ("cropped_bgr", "oriented_bgr", "original_bgr") + if (v := cached.get(k)) is not None), None) if img_bgr is None: raise HTTPException(status_code=400, detail="No image available for deskewing") @@ -589,7 +590,8 @@ async def manual_deskew(session_id: str, req: ManualDeskewRequest): await _load_session_to_cache(session_id) cached = _get_cached(session_id) - img_bgr = cached.get("cropped_bgr") or cached.get("oriented_bgr") or cached.get("original_bgr") + img_bgr = next((v for k in ("cropped_bgr", "oriented_bgr", "original_bgr") + if (v := cached.get(k)) is not None), None) if img_bgr is None: raise HTTPException(status_code=400, detail="No image available for deskewing") diff --git a/klausur-service/backend/orientation_crop_api.py b/klausur-service/backend/orientation_crop_api.py index 6fee2ce..531c117 100644 --- a/klausur-service/backend/orientation_crop_api.py +++ b/klausur-service/backend/orientation_crop_api.py @@ -174,7 +174,8 @@ async def auto_crop(session_id: str): cached = await _ensure_cached(session_id) # Use oriented image if available, else original - img_bgr = cached.get("oriented_bgr") or cached.get("original_bgr") + oriented = cached.get("oriented_bgr") + img_bgr = oriented if oriented is not None else cached.get("original_bgr") if img_bgr is None: raise HTTPException(status_code=400, detail="No image available for cropping") @@ -236,7 +237,8 @@ async def manual_crop(session_id: str, req: ManualCropRequest): """Manually crop using percentage coordinates.""" cached = await _ensure_cached(session_id) - img_bgr = cached.get("oriented_bgr") or cached.get("original_bgr") + oriented = cached.get("oriented_bgr") + img_bgr = oriented if oriented is not None else cached.get("original_bgr") if img_bgr is None: raise HTTPException(status_code=400, detail="No image available for cropping") @@ -294,7 +296,8 @@ async def skip_crop(session_id: str): """Skip cropping — use oriented (or original) image as-is.""" cached = await _ensure_cached(session_id) - img_bgr = cached.get("oriented_bgr") or cached.get("original_bgr") + oriented = cached.get("oriented_bgr") + img_bgr = oriented if oriented is not None else cached.get("original_bgr") if img_bgr is None: raise HTTPException(status_code=400, detail="No image available")