Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
h5_file = h5py.File(h5_path)
if 'layer_names' in h5_file.attrs:
model_json = None
groups = conversion.h5_weights_to_tfjs_format(
h5_file, split_by_layer=split_weights_by_layer)
else:
model_json, groups = conversion.h5_merged_saved_model_to_tfjs_format(
h5_file, split_by_layer=split_weights_by_layer)
if output_dir:
if os.path.isfile(output_dir):
raise ValueError(
'Output path "%s" already exists as a file' % output_dir)
if not os.path.isdir(output_dir):
os.makedirs(output_dir)
conversion.write_artifacts(
model_json, groups, output_dir, quantization_dtype,
weight_shard_size_bytes=weight_shard_size_bytes)
return model_json, groups
h5_file = h5py.File(h5_path)
if 'layer_names' in h5_file.attrs:
model_json = None
groups = conversion.h5_weights_to_tfjs_format(
h5_file, split_by_layer=split_weights_by_layer)
else:
model_json, groups = conversion.h5_merged_saved_model_to_tfjs_format(
h5_file, split_by_layer=split_weights_by_layer)
if output_dir:
if os.path.isfile(output_dir):
raise ValueError(
'Output path "%s" already exists as a file' % output_dir)
if not os.path.isdir(output_dir):
os.makedirs(output_dir)
conversion.write_artifacts(
model_json, groups, output_dir, quantization_dtype,
weight_shard_size_bytes=weight_shard_size_bytes)
return model_json, groups