Spaces:
Build error
Build error
Download annotator/midas/base_model.py from aki-0421/character-360: direct link, hf CLI and curl.
- Browser
- Download file 391 Bytes
-
https://huggingface.co/spaces/aki-0421/character-360/resolve/main/annotator/midas/base_model.py
- Command line
-
hf download hf://spaces/aki-0421/character-360/annotator/midas/base_model.py
-
curl -L -o base_model.py https://huggingface.co/spaces/aki-0421/character-360/resolve/main/annotator/midas/base_model.py
391 Bytes
| # -*- coding: utf-8 -*- | |
| import torch | |
| class BaseModel(torch.nn.Module): | |
| def load(self, path): | |
| """Load model from file. | |
| Args: | |
| path (str): file path | |
| """ | |
| parameters = torch.load(path, map_location=torch.device('cpu')) | |
| if 'optimizer' in parameters: | |
| parameters = parameters['model'] | |
| self.load_state_dict(parameters) | |