Onnx yolov3 postprocessing

Please provide the following information when requesting support.

• Hardware (NVIDIA RTX 3080Ti)
• Network Type (Yolo_v3)
• TLT Version (5.3.0)
• Training spec file(random_seed: 42
yolov3_config {
big_anchor_shape: “[(114.94, 60.67), (159.06, 114.59), (297.59, 176.38)]”
mid_anchor_shape: “[(42.99, 31.91), (79.57, 31.75), (56.80, 56.93)]”
small_anchor_shape: “[(15.60, 13.88), (30.25, 20.25), (20.67, 49.63)]”
matching_neutral_box_iou: 0.7
arch: “resnet”
nlayers: 18
arch_conv_blocks: 2
loss_loc_weight: 0.8
loss_neg_obj_weights: 100.0
loss_class_weights: 1.0
freeze_bn: false
#freeze_blocks: 0
force_relu: false
}
training_config {
batch_size_per_gpu: 8
num_epochs: 200
enable_qat: True
checkpoint_interval: 10
learning_rate {
soft_start_annealing_schedule {
min_learning_rate: 1e-6
max_learning_rate: 1e-4
soft_start: 0.1
annealing: 0.5
}
}
regularizer {
type: L1
weight: 3e-5
}
optimizer {
adam {
epsilon: 1e-7
beta1: 0.9
beta2: 0.999
amsgrad: false
}
}
pretrain_model_path: “/workspace/tao-experiments/sample/resnet_18.hdf5”
}
eval_config {
average_precision_mode: SAMPLE
batch_size: 8
matching_iou_threshold: 0.5
}
nms_config {
confidence_threshold: 0.001
clustering_iou_threshold: 0.5
top_k: 200
force_on_cpu: True
}
augmentation_config {
hue: 0.1
saturation: 1.5
exposure:1.5
vertical_flip:0
horizontal_flip: 0.5
jitter: 0.3
output_width: 384
output_height: 1248
output_channel: 3
randomize_input_shape_period: 0
}
dataset_config {
data_sources: {
tfrecords_path: “/workspace/tao-experiments/sample/dataset/tfrecords/tfrecords*”
image_directory_path: “/workspace/tao-experiments/sample/dataset/training”
}
include_difficult_in_training: true
image_extension: “png”
target_class_mapping {
key: “car”
value: “car”
}
target_class_mapping {
key: “pedestrian”
value: “pedestrian”
}
target_class_mapping {
key: “cyclist”
value: “cyclist”
}
target_class_mapping {
key: “van”
value: “car”
}
target_class_mapping {
key: “person_sitting”
value: “pedestrian”
}
validation_fold: 0
})
After converting the model to onnx I took inference need post processing code to draw the bounding boxes

You can refer to tao_tensorflow1_backend/nvidia_tao_tf1/cv/yolo_v3/scripts/inference.py at main · NVIDIA/tao_tensorflow1_backend · GitHub and tao_tensorflow1_backend/nvidia_tao_tf1/cv/common/inferencer/inferencer.py at main · NVIDIA/tao_tensorflow1_backend · GitHub.

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

i want to take inference on exported onnx model.