Test Image for classification

Hi guys,
I am testing my model for the same image and the prediction output is going different every time I run the code.

Capturar

model = loader(‘balanca.pth’)

classe = (‘Balanca’,‘False’)

model.eval()

img = Image.open(“ImgTest/All/0n.png”)

x = transform(img)

x = x.unsqueeze(0)

output = model(x)

pred = torch.argmax(output,1)

print(‘Image predict as:’,classe[pred])

Hi,
Did you set the random seed manually?


seed = 0
torch.manual_seed(seed)

torch.backends.cudnn.deterministic = True
torch.backends.cudnn.benchmark = False

import numpy as np
np.random.seed(seed)