This code is used for taking inference on hdf5 files or tlt formats, i need to take inference on exported models
def load_model(model_path, experiment_spec=None, input_shape=None, key=None):
“”“Load a model either in .tlt format or .hdf5 format.”“”
_, ext = os.path.splitext(model_path)
if ext == '.hdf5':
yololoss = YOLOv3Loss(experiment_spec.yolov3_config.loss_loc_weight,
experiment_spec.yolov3_config.loss_neg_obj_weights,
experiment_spec.yolov3_config.loss_class_weights,
experiment_spec.yolov3_config.matching_neutral_box_iou)
CUSTOM_OBJS['compute_loss'] = yololoss.compute_loss
# directly load model, add dummy loss since loss is never required.
if input_shape is None:
# load the model to get img width/height
model = load_keras_model(model_path,
custom_objects=CUSTOM_OBJS)
else:
input_layer = keras.layers.InputLayer(input_shape=input_shape, name="Input")
model = get_model_with_input(model_path, input_layer)
elif ext == '.tlt':
os_handle, temp_file_name = tempfile.mkstemp(suffix='.hdf5')
os.close(os_handle)
with open(temp_file_name, 'wb') as temp_file, open(model_path, 'rb') as encoded_file:
encoding.decode(encoded_file, temp_file, key)
encoded_file.close()
temp_file.close()
# recursive call
model = load_model(temp_file_name, experiment_spec, input_shape, None)
os.remove(temp_file_name)
else:
raise NotImplementedError("{0} file is not supported!".format(ext))
return model
There is no update from you for a period, assuming this is not an issue anymore. Hence we are closing this topic. If need further support, please open a new one. Thanks