from torch.autograd import Variable
import torch.nn.functional as F
from PIL import Image
data_transforms = transforms.Compose([
transforms.Resize(256),
transforms.CenterCrop(224),
transforms.ToTensor(),
transforms.Normalize([0.5,0.5,0.5], [0.5,0.5,0.5])
])


My code:
image='dudth.jpg'
image = Image.open(image).convert('RGB')
image=data_transforms(image)
image.unsqueeze(dim=0)
imgblob = Variable(image)
torch.no_grad()
predict = F.softmax(model_ft(imgblob))
print(predict)