@@ -51,12 +51,14 @@ def download_model(url, file_paths, file_sha256=None):
5151 else : # need to download the model
5252 model_file_url = f"{ url } /{ model_file_path } "
5353 keras .utils .get_file (
54- origin = model_file_url , fname = model_file_path ,
55- cache_dir = "." , cache_subdir = "./model"
54+ origin = model_file_url ,
55+ fname = model_file_path ,
56+ cache_dir = "." ,
57+ cache_subdir = "./model" ,
5658 )
5759
5860
59- def load_model (url , file_paths , file_sha256 = None , format = ' composite' ):
61+ def load_model (url , file_paths , file_sha256 = None , format = " composite" ):
6062 """
6163 Model reconstruction.
6264
@@ -70,7 +72,7 @@ def load_model(url, file_paths, file_sha256=None, format='composite'):
7072 file_sha256(str): the supposed hash of one of the files
7173 we need to download. Checked against the
7274 one we may already have in the codebase.
73- format(str): currently this only supports 'composite'
75+ format(str): currently this only supports 'composite'
7476 (which is for when the model is saved using a H5 + JSON)
7577 or 'h5' as the save format of the model.
7678
@@ -79,7 +81,7 @@ def load_model(url, file_paths, file_sha256=None, format='composite'):
7981 """
8082
8183 def _model_from_composite_format ():
82- ''' Specific to using H5 + JSON as the save format'''
84+ """ Specific to using H5 + JSON as the save format"""
8385 params_file , layers_file = file_paths
8486 # load the model in memory
8587 with open (f"./model/{ layers_file } " ) as f :
@@ -88,14 +90,14 @@ def _model_from_composite_format():
8890 return model
8991
9092 def _model_from_h5 ():
91- ''' Specific to using a single Hadoop(H5) file'''
93+ """ Specific to using a single Hadoop(H5) file"""
9294 params_file = file_paths [0 ]
9395 return keras .models .load_model (params_file )
94-
96+
9597 # First download the model, if needed
9698 download_model (url , file_paths , file_sha256 )
9799 # load the model in memory
98- if format == ' composite' :
100+ if format == " composite" :
99101 return _model_from_composite_format ()
100102 else : # assuming a single H5
101103 return _model_from_h5 ()
0 commit comments