Hi
I have used just that and printed the result
Image type:  torch.FloatTensor
shape without unsqueezing:  torch.Size([3, 10, 10])
After unsqueezing:  torch.Size([1, 3, 10, 10])
I was using VGG16 to detect person face jpg , as
Before unsqueezing it was giving error like

RuntimeError: expected stride to be a single integer value or a list of 1 values to match the convolution dimensions, but got stride=[1, 1]

after using  unsqueezeed image to  model as
vgg16(img.unsqueeze_(0))
again thrown error like this

RuntimeError: Given input size: (512x1x1). Calculated output size: (512x0x0). Output size is too small at /opt/conda/conda-bld/pytorch_1524584710464/work/aten/src/THNN/generic/SpatialDilatedMaxPooling.c:67

My code snippet as follow


Summary
    img_to_tensor =  transforms.Compose([
        transforms.CenterCrop(10),
        transforms.ToTensor(),
        transforms.Normalize((0.485, 0.456, 0.406), (0.229, 0.224, 0.225))
    ])
    img_pil = Image.open(img_path)
    img = img_to_tensor(img_pil)
#     print("Image type: ", img.type())
#     print("shape without unsqueezing: ", img.shape)
#     print("After unsqueezing: ",img.unsqueeze_(0).shape)
    prediction = VGG16(img.unsqueeze_(0))
    ## Return the *index* of the predicted class for that image
    

    return prediction # predicted class index


Please Help!!! .