| 22 | |
| 23 | class Inferer: |
| 24 | def __init__(self, config): |
| 25 | self.config = config |
| 26 | if torch.cuda.is_available(): |
| 27 | self.device = torch.device('cuda') |
| 28 | else: |
| 29 | self.device = torch.device('cpu') |
| 30 | torch.set_num_threads(1) |
| 31 | |
| 32 | # 0. Construct preprocessors |
| 33 | self.model_preproc = registry.instantiate( |
| 34 | registry.lookup('model', config['model']).Preproc, |
| 35 | config['model']) |
| 36 | self.model_preproc.load() |
| 37 | |
| 38 | def load_model(self, logdir, step): |
| 39 | '''Load a model (identified by the config used for construction) and return it''' |