Created
September 13, 2021 12:04
-
-
Save Borda/4bf6e0cfa84a973b0f3ea595839ef241 to your computer and use it in GitHub Desktop.
Simple Submitting Kernel to Kaggle Competition
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| preds = [] | |
| # move model to GPU for faster inference and set evaluation | |
| model.cuda().eval() | |
| for imgs, names in dm.test_dataloader(): | |
| # for the prediction we do not need gradients | |
| with torch.no_grad(): | |
| onehots = model(imgs.cuda()).cpu() | |
| # aggregate particular preditions | |
| for oh, name in zip(onehots, names): | |
| lbs = dm.onehot_to_labels(oh) | |
| preds.append(dict(image=name, labels=" ".join(lbs[::-1]))) | |
| df_preds = pd.DataFrame(preds) | |
| # show sample predictions | |
| print(df_preds.head()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment