MAE-pytorch icon indicating copy to clipboard operation
MAE-pytorch copied to clipboard

MAE prediction visualization code

Open tikboaHIT opened this issue 3 years ago • 9 comments

Thank you for your contribution. I wonder if you plan to release the mask prediction visualization code?

tikboaHIT avatar Nov 17 '21 13:11 tikboaHIT

Unfortunately, our current visualization code also has some bugs, I will try to solve it!

pengzhiliang avatar Nov 18 '21 03:11 pengzhiliang

I have implemented the visualization code here, can I submit a merge request?

tikboaHIT avatar Nov 18 '21 03:11 tikboaHIT

Of course. Thank you for your contributions.

And can you provide some visualization results here?

pengzhiliang avatar Nov 18 '21 04:11 pengzhiliang

Of course, can you provide pre-trained models and test images? Because the current model is mainly based on a custom datset.

tikboaHIT avatar Nov 18 '21 05:11 tikboaHIT

I have uploaded the weight to google drive, please see latest readme.txt.

pengzhiliang avatar Nov 19 '21 07:11 pengzhiliang

Hi, I was wondering how to perform inference and run the full encoder-decoder network on a complete, unmasked image? In other words, after it is trained, how would I call the model such that it encodes a complete image with no masks, and then reconstructs the original image using the decoder?

avitrost avatar Nov 19 '21 20:11 avitrost

Hello, @avitrost , maybe there are some bugs now when the mask is always 0. But if you really want to observe the performance when MAE is used as a pure auto-encoder, you should have a change: For the encoder: you can directly let x_vis=x in this line. And for the inputs to decoder:

x_vis = self.encoder_to_decoder(x_vis) # [B, N_vis, C_d]
B, N, C = x_vis.shape
expand_pos_embed = self.pos_embed.expand(B, -1, -1).type_as(x).to(x.device).clone().detach()
pos_emd_vis = expand_pos_embed[~mask].reshape(B, -1, C)
pos_emd_mask = expand_pos_embed[mask].reshape(B, -1, C)
x_full = torch.cat([x_vis + pos_emd_vis, self.mask_token + pos_emd_mask], dim=1)

x = self.decoder(x_full, pos_emd_mask.shape[1]) # [B, N_mask, 3 * 16 * 16]

It needs to be changed to:

x_vis = self.encoder_to_decoder(x_vis) # [B, N, C_d]
expand_pos_embed = self.pos_embed.expand(B, -1, -1).type_as(x).to(x.device).clone().detach()
x = self.decoder(x_vis+expand_pos_embed , x_vis.shape[1]) # [B, N, 3 * 16 * 16]

Maybe there will be some other bugs, you can have a debug. Hope this can help you!

pengzhiliang avatar Nov 20 '21 16:11 pengzhiliang

expand_pos_embed = self.pos_embed

Thank you for your contribution! I have a question about this change. Why this change does not update in the latest code?

Pter61 avatar Dec 14 '21 09:12 Pter61

Hello, I would like to ask if the weight file loaded visually is the pre-trained weight file or the fine-tuned weight file? Error when I load the fine-tuned weight file: image

mouxinyue1 avatar Nov 18 '22 07:11 mouxinyue1