FastMOT
FastMOT copied to clipboard
YOLOX preprocessing
I am trying to Implement YOLOX in FastMOT. Can you tell me if I need to modify preprocessing for the Yolo class. Here's the preprocessing code of YoloX. Can I achieve this by setting letterbox to True
def yolox_nano_preproc(self, img, input_size, swap=(2, 0, 1)):
img = cv2.resize(img, (416,416))
if len(img.shape) == 3:
padded_img = np.ones((input_size[0], input_size[1], 3), dtype=np.uint8) * 114
print("padded_img.shape: ",padded_img.shape)
print("padded_img: ",padded_img)
else:
padded_img = np.ones(input_size, dtype=np.uint8) * 114
r = min(input_size[0] / img.shape[0], input_size[1] / img.shape[1])
print("r: ",r)
resized_img = cv2.resize(
img,
(int(img.shape[1] * r), int(img.shape[0] * r)),
interpolation=cv2.INTER_LINEAR,
).astype(np.uint8)
print("resized_img: ",resized_img)
cv2.imshow("resized_img: ",resized_img)
padded_img[: int(img.shape[0] * r), : int(img.shape[1] * r)] = resized_img
cv2.imshow("padded_img: ",padded_img)
padded_img = padded_img.transpose(swap)
print("padded_img trans: ",padded_img)
padded_img = np.ascontiguousarray(padded_img, dtype=np.float32)
​
padded_img = np.expand_dims(padded_img, axis=0)
return padded_img, r