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

使用atlas200dk推理的前处理 #1

Open
bigonestep opened this issue Dec 22, 2021 · 5 comments
Open

使用atlas200dk推理的前处理 #1

bigonestep opened this issue Dec 22, 2021 · 5 comments

Comments

@bigonestep
Copy link

    def pre_process(self, image):
        image_padded = np.ones([self.input_size[0], self.input_size[1], 3], dtype=np.float32) * 114.0
        r = min(self.input_size[0]/image.shape[0], self.input_size[1]/image.shape[1])
        image_resized = cv2.resize(image, (int(image.shape[1] * r), int(image.shape[0] * r)), cv2.INTER_LINEAR)
        image_padded[:int(image.shape[0] * r), :int(image.shape[1] * r), :] = image_resized

        img = image_padded[:, :, ::-1]
        img = (img - self.mean)/self.std
    
        img = np.concatenate([img[::2, ::2, :], img[1::2, ::2, :], 
                              img[::2, 1::2, :], img[1::2, 1::2, :]], axis=-1)
    
        img = np.expand_dims(img.transpose((2, 0, 1)), axis=0)
        inp = np.ascontiguousarray(img, dtype=np.float32)
        return inp, r, image_padded.astype(np.uint8)

为什么要做这一步处理呢?

img = np.concatenate([img[::2, ::2, :], img[1::2, ::2, :], 
                      img[::2, 1::2, :], img[1::2, 1::2, :]], axis=-1)

我看到使用 opencv 的 dnn 推理没有这一步啊。这一步在 atlas 上面花费了很多的时间。

@stunback
Copy link
Collaborator

Opencv dnn支持Focus这个操作。Atlas不支持focus,所以我把模型里的Focus操作,移到预处理里进行。

@wangzhihui22
Copy link

可以提供一下,yoloX其他版本(tiny、s)转换之后的权重么?

@stunback
Copy link
Collaborator

stunback commented Feb 12, 2022 via email

@wangzhihui22
Copy link

尝试按照readme中的步骤转换的yolox-tiny,检测不出目标,转换过程没有报错。请问一下,是不是因为onnx的版本问题,还是因为过程中需要修改一些参数?

@WT0327
Copy link

WT0327 commented May 17, 2023

我也是,模型转换不报错,但是检测不出目标

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

4 participants