PyVGGFace
PyVGGFace copied to clipboard
May I ask how to preprocess the input image?
Hi @maxwellgodv, as you can see in the demo script, I'm using OpenCV to read and resize the input image, before I convert it into a torch tensor:
# Load test image and resize to 224x224
img = cv2.imread(args.img)
img = cv2.resize(img, (224, 224))
# Forward test image through VGGFace
img = torch.Tensor(img).permute(2, 0, 1).view(1, 3, 224, 224).double()
img -= torch.Tensor(np.array([129.1863, 104.7624, 93.5940])).double().view(1, 3, 1, 1)
Is that what you mean?