Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

YOLOX preprocessing #217

Open
umairjavaid opened this issue Oct 22, 2021 · 0 comments
Open

YOLOX preprocessing #217

umairjavaid opened this issue Oct 22, 2021 · 0 comments

Comments

@umairjavaid
Copy link

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant