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

Image alignment and preprocessing for pre-trained model #26

Open
JoMe2704 opened this issue Dec 10, 2020 · 0 comments
Open

Image alignment and preprocessing for pre-trained model #26

JoMe2704 opened this issue Dec 10, 2020 · 0 comments

Comments

@JoMe2704
Copy link

JoMe2704 commented Dec 10, 2020

I wonder, how to prepare the images in order to use the pre-trained model.

  1. I guess that the images should be aligned and resized to 112x112, right? Your code also supports 224x224, but on what images has the pre-trained net been trained? I guess on 112x112, because when I try 224x224, I get a 'RuntimeError: size mismatch'.

  2. How was alignment and resizing exactly done. You refer to the val data in https://github.com/ZhaoJ9014/face.evoLVe.PyTorch. However, the cropped images of CFP (Version "Align_112x112") linked in the Data Zoo there are cropped differently than the code of that repository does. Can you give one or two examples of aligned and resized images used to train the pre-trained model?

  3. The script utils.py contains the following function for preprocessing (after alignment and resizing):
    ccrop = transforms.Compose([ de_preprocess, transforms.ToPILImage(), transforms.ToTensor(), transforms.Normalize([0.5, 0.5, 0.5], [0.5, 0.5, 0.5]) ])
    with
    def de_preprocess(tensor): return tensor * 0.5 + 0.5
    It seems, that the validation data had already been normalized (mean, std), and here, you revert that to an image tensor, but then apply the same normalization again. So, I think, when performing inference on a single (aligned and resized) image, I should just use input_tensor = preprocess(croppedImg).unsqueeze(0) using this transform:
    preprocess = transforms.Compose([ transforms.ToTensor(), transforms.Normalize([0.5, 0.5, 0.5], [0.5, 0.5, 0.5]) ])
    Is this assumption right?

You help is much appreciated.

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