PyVGGFace icon indicating copy to clipboard operation
PyVGGFace copied to clipboard

May I ask how to preprocess the input image?

Open maxwellgodv opened this issue 2 years ago • 1 comments

maxwellgodv avatar May 25 '23 09:05 maxwellgodv

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?

chi0tzp avatar May 26 '23 12:05 chi0tzp