def load_url(url, model_dir=None):
 if (model_dir is None):
  torch_home = os.path.expanduser(os.getenv('TORCH_HOME', '~/.torch'))
  model_dir = os.getenv('TORCH_MODEL_ZOO', os.path.join(torch_home, 'models'))
 if (not os.path.exists(model_dir)):
  os.makedirs(model_dir)
 parts = urlparse(url)
 filename = os.path.basename(parts.path)
 cached_file = os.path.join(model_dir, filename)
 if (not os.path.exists(cached_file)):
  sys.stderr.write('Downloading: "{}" to {}\n'.format(url, cached_file))
  hash_prefix = HASH_REGEX.search(filename).group(1)
  _download_url_to_file(url, cached_file, hash_prefix)
 return torch.load(cached_file)

def load_url ( url , model_dir = None ) : if ( model_dir is None ) : torch_home = os . path . expanduser ( os . getenv ( 'TORCH_HOME' , '~/.torch' ) ) model_dir = os . getenv ( 'TORCH_MODEL_ZOO' , os . path . join ( torch_home , 'models' ) ) if ( not os . path . exists ( model_dir ) ) : os . makedirs ( model_dir ) parts = urlparse ( url ) filename = os . path . basename ( parts . path ) cached_file = os . path . join ( model_dir , filename ) if ( not os . path . exists ( cached_file ) ) : sys . stderr . write ( 'Downloading: "{}" to {}\n' . format ( url , cached_file ) ) hash_prefix = HASH_REGEX . search ( filename ) . group ( 1 ) _download_url_to_file ( url , cached_file , hash_prefix ) return torch . load ( cached_file )
loads the torch serialized object at the given url .