[6d4adb]: / Preprocessing / preprocessing.py

Download this file

16 lines (12 with data), 402 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
import cv2
import torch
class Preprocessor:
def __init__(self, width, height, inter=cv2.INTER_AREA):
self.width = width
self.height = height
self.inter = inter
def preprocess(self, image):
image = image / 255
image = cv2.resize(image, (self.width, self.height), interpolation=self.inter)
# image = torch.from_numpy(image)
return image