Please some one help me.
I have written the following code.
import torch
import torchvision.models as models
import numpy as np
import matplotlib.pyplot as plt
import torchvision.transforms as transforms
import cv2
image=cv2.imread(‘Dog.jpg’)
image is numpy array
cv2.imshow(‘Display’,image);cv2.waitKey(10000);cv2.destroyAllWindows()
image1 =  transforms.ToTensor()(image)
image1 is Tensor
image2=transforms.ToPILImage()(image1)
image2 is PIL image
image3=transforms.Resize((224,224))(image2)
#image3 is Resized Image
image4 =  transforms.ToTensor()(image3)
image4 is Tensor
image4=transforms.Normalize(mean=[0.485, 0.456, 0.406],std=[0.229, 0.224, 0.225])(image4)
image4=torch.unsqueeze(image4,0)
densenet=models.densenet161(pretrained=True)
output=densenet(image4)
predictions=output.max(1)
##########################################################
Dog image is as shown…

Dog.jpg1280×620 72.4 KB

I got the output as:
predictions : (tensor([ 2.0526]), tensor([ 463]))
From standard Imagenet labels ,463 corresponds to bucket or pail.
Why I am not getting coorect label???