Created
September 13, 2018 16:19
-
-
Save mahasak/1dd12f77978fc0eeac58845d185e6ffd to your computer and use it in GitHub Desktop.
Pytorch load model
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
| import torch | |
| from torch import nn | |
| from torchvision.models import resnet50 | |
| def load_model(): | |
| global model | |
| model = resnet50(pretrained=False) | |
| model_path = "./models/resnet50-19c8e357.pth" | |
| checkpoint = torch.load(model_path) | |
| model.load_state_dict(checkpoint) | |
| model.eval() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment