RishiTest / models /misc_utils.py
Lemorra's picture
InternVL3-1B model app
ba9f758
raw
history blame
425 Bytes
import cv2
import numpy as np
import base64
from PIL import Image
def convert_base64_to_cv2(base64_string: str):
return cv2.imdecode(np.frombuffer(base64.b64decode(base64_string), np.uint8), cv2.IMREAD_COLOR)
def convert_cv2_to_pil(image: np.ndarray):
return Image.fromarray(image).convert('RGB')
def convert_base64_to_pil(base64_string: str):
return convert_cv2_to_pil(convert_base64_to_cv2(base64_string))