From ac307c5cfa57e5e10f372183e3cf3a9270868e3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Bournhonesque?= Date: Mon, 28 Oct 2024 11:00:44 +0100 Subject: [PATCH] fix: convert image to RGB before nutrition extraction --- robotoff/prediction/nutrition_extraction.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/robotoff/prediction/nutrition_extraction.py b/robotoff/prediction/nutrition_extraction.py index 5f2d128b69..668a6929e4 100644 --- a/robotoff/prediction/nutrition_extraction.py +++ b/robotoff/prediction/nutrition_extraction.py @@ -138,6 +138,10 @@ def preprocess( words = [] char_offsets = [] bboxes = [] + + if image.mode != "RGB": + image = image.convert("RGB") + width, height = image.size for page in ocr_result.full_text_annotation.pages: for block in page.blocks: