Cannot produce calibration binary for INT8 compression with YOLOv4

• Hardware: NVIDIA GeForce GTX 1080 Ti
• Network Type: YOLOv4
• TAO Version YOLOv4: 4.0.0-tf1.15.5:

This topic is a continuation of the following one:

I’m having the same issue described in this thread: unable to understand how to produce the Yolov4 calibration cache (calibration.bin) required for engine generation in INT8 format. The TAO TK v4.0.1 documentation says the following:

If tao yolo_v4 export is run with the --data_type flag set to int8 , the calibration cache is generated using a calibration tensor file.

Q1: How can we generate this calibration tensor file for Yolo_v4 architecture?

From my understanding of below diagram from DetectNet_v2 doc, with DetectNet_v2 architecture we have access to the calibration_tensorfile function to generate this calibration tensor file. However, this is not an option with Yolo_v4 architecture. The diagram also indicates that for Yolo_v4, the calibration.bin should be generated directly with the export function using the .tlt model and the training images as input.

Thus, there is some contradiction between the Yolo_v4 doc and the DetecNet_v2 diagram. Please clarify whether we need to generate the calibration tensor file prior to the calibration.bin file to use it as input of the yolo_v4 export command.

Q2: If we do not need to generate a calibration tensor file prior to the calibration.bin export, how can we use the yolo_v4 export to generate the calibration binary?

I have the exact same issue as described in the topic referred at the top. If I omit the --cal_data_file in the export query, it gives me a missing file error ; as if the tensor file is needed as an input (see printout below). If I include the --cal_data_file parameter, as proposed in the previous topic, then the error message says it cannot find the /export/cal.tensorfile, which really gives us a hint that this argument is for input and not ouput.

yolo_v4 export -m $EXPERIMENT_DIR_DOCK/experiment_dir_retrain/weights/yolov4_mobilenet_v2_epoch_120.tlt  \
                                -o $EXPERIMENT_DIR_DOCK/yolov4_mobilenet_v2_epoch_120_int8.etlt \
                                -e $SPECS_DIR_DOCK/yolo_v4_retrain_mobilenet_v2_coco.txt \
                                -k $KEY \
                                --cal_image_dir  $DATA_DIR_DOCK/training/train \
                                --data_type int8 \
                                --batch_size 16 \
                                --batches 50 \
                                --cal_cache_file $EXPERIMENT_DIR_DOCK/export/cal.bin'

2023-05-31 19:46:00,023 [INFO] keras2onnx: The ONNX operator number change on the optimization: 688 → 303
Traceback (most recent call last):
File “</usr/local/lib/python3.6/dist-packages/iva/yolo_v4/scripts/>”, line 3, in
File “”, line 12, in
File “”, line 302, in launch_export
File “”, line 284, in run_export
File “”, line 410, in export
File “”, line 198, in get_calibrator
File “”, line 323, in generate_tensor_file
File “”, line 54, in init
File “/usr/local/lib/python3.6/dist-packages/h5py/_hl/”, line 312, in init
fid = make_fid(name, mode, userblock_size, fapl, swmr=swmr)
File “/usr/local/lib/python3.6/dist-packages/h5py/_hl/”, line 148, in make_fid
fid = h5f.create(name, h5f.ACC_TRUNC, fapl=fapl, fcpl=fcpl)
File “h5py/_objects.pyx”, line 54, in h5py._objects.with_phil.wrapper
File “h5py/_objects.pyx”, line 55, in h5py._objects.with_phil.wrapper
File “h5py/h5f.pyx”, line 98, in h5py.h5f.create
ValueError: Invalid file name (invalid file name)
Telemetry data couldn’t be sent, but the command ran successfully.
[WARNING]: <urlopen error [Errno -2] Name or service not known>
Execution status: FAIL

Thanks for your support

Alright, it finally went through. Not too sure what was going wrong before.

TAO_COMMAND = ' yolo_v4 export -m $EXPERIMENT_DIR_DOCK/experiment_dir_retrain/weights/yolov4_mobilenet_v2_epoch_120.tlt  \
                                -o $EXPERIMENT_DIR_DOCK/export_cmd/yolov4_mobilenet_v2_epoch_120_int8.etlt \
                                -e $SPECS_DIR_DOCK/yolo_v4_retrain_mobilenet_v2_coco.txt \
                                -k $KEY \
                                --cal_image_dir  $DATA_DIR_DOCK/training/train \
                                --data_type int8 \
                                --batch_size 16 \
                                --batches 50 \
                                --cal_cache_file $EXPERIMENT_DIR_DOCK/export_cmd/cal.bin \
                                --cal_data_file $EXPERIMENT_DIR_DOCK/export_cmd/cal.tensorfile'

                                #--batch_size 16 \
                                #--batches 10 \
                                #--cal_data_file $EXPERIMENT_DIR_DOCK/export/cal.tensorfile
                                #--cal_cache_file $EXPERIMENT_DIR_DOCK/export/cal.bin'

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.