nussl/separation/base/deep_mixin.py
def load_model(self, model_path, device='cpu'):
        """
        Loads the model at specified path `model_path`. Uses GPU if
        available.

        Args:
            model_path (str): path to model saved as SeparationModel.
            device (str or torch.Device): loads model on CPU or GPU. Defaults to
              'cuda'.

        Returns:
            model (SeparationModel): Loaded model, nn.Module
            metadata (dict): metadata associated with model, used for making
            the input data into the model.
        """
        safe_loader = SafeModelLoader()
        model_dict = safe_loader.load(model_path, 'cpu')
        metadata = model_dict['metadata']

        model = SeparationModel(metadata['config'])
        model.load_state_dict(model_dict['state_dict'])
        device = device if torch.cuda.is_available() else 'cpu'

        self.device = device

        model = model.to(device).eval()
        self.model = model
        self.config = metadata['config']
        self.metadata.update(metadata)
        self.transform = self._get_transforms(metadata['train_dataset']['transforms'])

        Loads the model at specified path `model_path`. Uses GPU if
        available.

        Args:
            model_path (str): path to model saved as SeparationModel.
            device (str or torch.Device): loads model on CPU or GPU. Defaults to
              'cuda'.

        Returns:
            model (SeparationModel): Loaded model, nn.Module
            metadata (dict): metadata associated with model, used for making
            the input data into the model.
        
Loads the model at specified path `model_path`. Uses GPU if
available.
Loads the model at specified path ` model_path ` . Uses GPU if available .
def load_model(self, model_path, device='cpu'):
        safe_loader = SafeModelLoader()
        model_dict = safe_loader.load(model_path, 'cpu')
        metadata = model_dict['metadata']
        model = SeparationModel(metadata['config'])
        model.load_state_dict(model_dict['state_dict'])
        device = device if torch.cuda.is_available() else 'cpu'
        self.device = device
        model = model.to(device).eval()
        self.model = model
        self.config = metadata['config']
        self.metadata.update(metadata)
        self.transform = self._get_transforms(metadata['train_dataset']['transforms'])
def load_model ( self , model_path , device = 'cpu' ) : safe_loader = SafeModelLoader ( ) model_dict = safe_loader . load ( model_path , 'cpu' ) metadata = model_dict [ 'metadata' ] model = SeparationModel ( metadata [ 'config' ] ) model . load_state_dict ( model_dict [ 'state_dict' ] ) device = device if torch . cuda . is_available ( ) else 'cpu' self . device = device model = model . to ( device ) . eval ( ) self . model = model self . config = metadata [ 'config' ] self . metadata . update ( metadata ) self . transform = self . _get_transforms ( metadata [ 'train_dataset' ] [ 'transforms' ] )
Loads the model at specified path `model_path`.
Loads the model at specified path ` model_path ` .
"""
        Loads the model at specified path `model_path`. Uses GPU if
        available.

        Args:
            model_path (str): path to model saved as SeparationModel.
            device (str or torch.Device): loads model on CPU or GPU. Defaults to
              'cuda'.

        Returns:
            model (SeparationModel): Loaded model, nn.Module
            metadata (dict): metadata associated with model, used for making
            the input data into the model.
        """
model (SeparationModel): Loaded model, nn.Module
metadata (dict): metadata associated with model, used for making
the input data into the model.
model ( SeparationModel ) : Loaded model nn . Module metadata ( dict ) : metadata associated with model used for making the input data into the model .
self
model_path
path to model saved as SeparationModel.
path to model saved as SeparationModel .
device
loads model on CPU or GPU. Defaults to
'cuda'.
loads model on CPU or GPU . Defaults to ' cuda ' .