Skip to content

Instantly share code, notes, and snippets.

@khalidmeister
Last active June 24, 2020 04:17
Show Gist options
  • Save khalidmeister/39933abe43fefccc80d8fc718e1da2bc to your computer and use it in GitHub Desktop.
Save khalidmeister/39933abe43fefccc80d8fc718e1da2bc to your computer and use it in GitHub Desktop.
Testing the model and show the result
# Show the images and the ground truth
dataiter = iter(dataloaders['test'])
images, labels = dataiter.next()
imshow(torchvision.utils.make_grid(images))
print('GroundTruth: ', ', '.join('%5s' % class_names[x] for x in labels))
# Predict the model
images = images.to(device)
labels = images.to(device)
output = model_resnet(images)
_, predicted = torch.max(output, 1)
print('Predicted: ', ', '.join('%5s' % class_names[x] for x in predicted))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment