def load_model(self, directory, epoch=None):
    if (not directory):
        print('Note that load_model() is skipped as no pretrained model is given')
        return
    names = self.get_model_names()
    model_file = 'model-best.pth.tar'
    if (epoch is not None):
        model_file = ('model.pth.tar-' + str(epoch))
    for name in names:
        model_path = osp.join(directory, name, model_file)
        if (not osp.exists(model_path)):
            raise FileNotFoundError('Model not found at "{}"'.format(model_path))
        checkpoint = load_checkpoint(model_path)
        state_dict = checkpoint['state_dict']
        epoch = checkpoint['epoch']
        print('Loading weights to {} from "{}" (epoch = {})'.format(name, model_path, epoch))
        self._models[name].load_state_dict(state_dict)
def load_model(self, directory, epoch=None):
    if (not directory):
        print('Note that load_model() is skipped as no pretrained model is given')
        return
    names = self.get_model_names()
    model_file = 'model-best.pth.tar'
    if (epoch is not None):
        model_file = ('model.pth.tar-' + str(epoch))
    for name in names:
        model_path = osp.join(directory, name, model_file)
        if (not osp.exists(model_path)):
            raise FileNotFoundError('Model not found at "{}"'.format(model_path))
        checkpoint = load_checkpoint(model_path)
        state_dict = checkpoint['state_dict']
        epoch = checkpoint['epoch']
        print('Loading weights to {} from "{}" (epoch = {})'.format(name, model_path, epoch))
        self._models[name].load_state_dict(state_dict)