Spaces:
No application file
No application file
File size: 251 Bytes
be8eafa |
1 2 3 4 5 6 7 8 9 10 11 |
import numpy as np
import cv2
from PIL import Image
def preprocess_image(image: Image.Image):
# Convert PIL to OpenCV
img = np.array(image)
if img.shape[-1] == 4:
img = img[..., :3]
return cv2.cvtColor(img, cv2.COLOR_RGB2BGR)
|