From 6a3b162ca3c699ba78a5e6305157808786b3b9bb Mon Sep 17 00:00:00 2001 From: Patrick von Platen Date: Sat, 28 Sep 2024 12:28:45 +0200 Subject: [PATCH] up --- src/mistral_common/tokens/tokenizers/multimodal.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/mistral_common/tokens/tokenizers/multimodal.py b/src/mistral_common/tokens/tokenizers/multimodal.py index 153aadd..cd118b2 100644 --- a/src/mistral_common/tokens/tokenizers/multimodal.py +++ b/src/mistral_common/tokens/tokenizers/multimodal.py @@ -1,4 +1,5 @@ import base64 +import logging from dataclasses import dataclass from io import BytesIO from typing import Tuple, Union @@ -14,6 +15,9 @@ SpecialImageIDs, ) +logger = logging.getLogger(__name__) + + _cv2_installed: bool try: import cv2 @@ -21,6 +25,14 @@ _cv2_installed = True except ImportError: _cv2_installed = False +except Exception: + # cv2 has lots of import problems: https://github.com/opencv/opencv-python/issues/884 + # for better UX, let's simple skip import errors for now + logger.warn( + "You seem to have a broken installation of opencv. " + "Please follow : https://github.com/opencv/opencv-python/issues/884 to correct your environment." + " Skipped cv2 import." + ) def is_cv2_installed() -> bool: