Haoqing-Wang / LocalMIM

[CVPR 2023 Highlight] Masked Image Modeling with Local Multi-Scale Reconstruction
40 stars 2 forks source link

transform result to image #7

Open mixxs opened 3 weeks ago

mixxs commented 3 weeks ago

Hello, how to convert the output of mim_swin_base_patch4_win7 to an image

mixxs commented 3 weeks ago

I've tried using the following function to convert the output to an image, but it doesn't seem to work def unpatchify(self, x): """ x: (N, L, patch_size*2 3) imgs: (N, 3, H, W) """ N, L, Hid = x.shape patch_size = int((Hid / 3) 0.5) h = w = int(L 0.5) imgs = x.reshape((N, h, w, patch_size, patch_size, 3)) imgs = torch.einsum('nhwpqc->nchpwq', imgs) imgs = imgs.reshape((N, 3, h patch_size, w patch_size))

    return imgs