Loading

packnet_sfm.utils.load.backwards_state_dict(state_dict)[source]

Modify the state dict of older models for backwards compatibility

Parameters

state_dict (dict) – Model state dict with pretrained weights

Returns

state_dict – Updated model state dict with modified layer names

Return type

dict

packnet_sfm.utils.load.filter_args(func, keys)[source]

Filters a dictionary so it only contains keys that are arguments of a function

Parameters
  • func (Function) – Function for which we are filtering the dictionary

  • keys (dict) – Dictionary with keys we are filtering

Returns

filtered – Dictionary containing only keys that are arguments of func

Return type

dict

packnet_sfm.utils.load.filter_args_create(func, keys)[source]

Filters a dictionary so it only contains keys that are arguments of a function and creates a function with those arguments

Parameters
  • func (Function) – Function for which we are filtering the dictionary

  • keys (dict) – Dictionary with keys we are filtering

Returns

func – Function with filtered keys as arguments

Return type

Function

packnet_sfm.utils.load.load_class(filename, paths, concat=True)[source]

Look for a file in different locations and return its method with the same name Optionally, you can use concat to search in path.filename instead

Parameters
  • filename (str) – Name of the file we are searching for

  • paths (str or list of str) – Folders in which the file will be searched

  • concat (bool) – Flag to concatenate filename to each path during the search

Returns

method – Loaded method

Return type

Function

packnet_sfm.utils.load.load_class_args_create(filename, paths, args={}, concat=True)[source]

Loads a class (filename) and returns an instance with filtered arguments (args)

packnet_sfm.utils.load.load_network(network, path, prefixes='')[source]

Loads a pretrained network

Parameters
  • network (nn.Module) – Network that will receive the pretrained weights

  • path (str) – File containing a ‘state_dict’ key with pretrained network weights

  • prefixes (str or list of str) – Layer name prefixes to consider when loading the network

Returns

network – Updated network with pretrained weights

Return type

nn.Module

packnet_sfm.utils.load.set_debug(debug)[source]

Enable or disable debug terminal logging

Parameters

debug (bool) – Debugging flag (True to enable)