Nawinkumar15 commited on
Commit
be8eafa
·
verified ·
1 Parent(s): aaaf2f8

Create utils/image_processing.py

Browse files
Files changed (1) hide show
  1. utils/image_processing.py +10 -0
utils/image_processing.py ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ import numpy as np
2
+ import cv2
3
+ from PIL import Image
4
+
5
+ def preprocess_image(image: Image.Image):
6
+ # Convert PIL to OpenCV
7
+ img = np.array(image)
8
+ if img.shape[-1] == 4:
9
+ img = img[..., :3]
10
+ return cv2.cvtColor(img, cv2.COLOR_RGB2BGR)