Spaces:
Runtime error
Runtime error
Download ercbcm/model_loader.py from erc/entity-referring-classifier: direct link, hf CLI and curl.
- Browser
- Download file 321 Bytes
-
https://huggingface.co/spaces/erc/entity-referring-classifier/resolve/main/ercbcm/model_loader.py
- Command line
-
hf download hf://spaces/erc/entity-referring-classifier/ercbcm/model_loader.py
-
curl -L -o model_loader.py https://huggingface.co/spaces/erc/entity-referring-classifier/resolve/main/ercbcm/model_loader.py
321 Bytes
| import torch | |
| def load(load_path, model, device): | |
| if load_path == None: return | |
| state_dict = torch.load(load_path, map_location=device) | |
| model.load_state_dict(state_dict['model_state_dict']) | |
| print('[LOAD] Model has been loaded successfully from \'{}\''.format(load_path)) | |
| return state_dict['valid_loss'] |