vit-pytorch icon indicating copy to clipboard operation
vit-pytorch copied to clipboard

The model output appears to be random when I use my image?

Open hustCYQ opened this issue 2 years ago • 0 comments

My code:

`if name == 'main': import torch import cv2 input_size = 224 img = cv2.imread("OIP-C.jpg") img = cv2.resize(img,(224,224)) img = rearrange(img, 'h w c -> c h w') img = repeat(img,'c h w -> b c h w',b=1) print(img.shape) img = torch.Tensor(img).cuda()

v = VIT_B16_224()

v.load_state_dict(torch.load('imagenet21k+imagenet2012_ViT-B_16-224.pth'))
v.cuda()
preds = v(img) # (1, 1000)
preds = torch.softmax(preds,-1)
print(preds.flatten())
print(torch.max(preds.flatten()))`

and the output is different each time.

hustCYQ avatar Apr 11 '22 02:04 hustCYQ