TAO v5.5.0

CenterPose 与 TAO Deploy

要生成优化的 TensorRT 引擎

  1. 使用 tao model centerpose export 生成 CenterPose .onnx 文件。

  2. .onnx 文件指定为 tao deploy centerpose gen_trt_engine 的输入。

有关训练 CenterPose 模型的更多信息,请参阅CenterPose 训练文档

要转换 .onnx 文件,您可以重复使用 tao model centerpose export 命令中的 spec 文件。

gen_trt_engine

gen_trt_engine 参数定义 TensorRT 引擎生成。

复制
已复制!
            

gen_trt_engine: onnx_file: /path/to/onnx_file trt_engine: /path/to/trt_engine input_channel: 3 input_width: 512 input_height: 512 tensorrt: data_type: fp32 workspace_size: 1024 min_batch_size: 1 opt_batch_size: 2 max_batch_size: 4 calibration: cal_image_dir: /path/to/cal/images cal_cache_file: /path/to/cal.bin cal_batch_size: 10 cal_batches: 1000

参数 数据类型 默认值 描述 支持的值
onnx_file 字符串 用于 TensorRT 引擎的精度
trt_engine 字符串 TensorRT 引擎的最大工作区大小
input_channel 无符号整数 3 输入通道大小。仅支持值 3。 3
input_width 无符号整数 512 输入宽度 >0
input_height 无符号整数 512 输入高度 >0
batch_size 无符号整数 -1 ONNX 模型的批次大小 >=-1

tensorrt

tensorrt 参数定义 TensorRT 引擎生成。

参数 数据类型 默认值 描述 支持的值
data_type 字符串 fp32 用于 TensorRT 引擎的精度 fp32/fp16/int8
workspace_size 无符号整数 1024 TensorRT 引擎的最大工作区大小 >1024
min_batch_size 无符号整数 1 用于优化配置文件形状的最小批次大小 >0
opt_batch_size 无符号整数 1 用于优化配置文件形状的最佳批次大小 >0
max_batch_size 无符号整数 1 用于优化配置文件形状的最大批次大小 >0

calibration

calibration 参数定义使用 PTQ INT8 校准的 TensorRT 引擎生成。

参数 数据类型 默认值 描述 支持的值
cal_image_dir 字符串 包含用于校准的图像的路径列表
cal_cache_file 字符串 要转储的校准缓存文件的路径
cal_batch_size 无符号整数 1 校准期间每个批次的批次大小 >0
cal_batches 无符号整数 1 要校准的批次数量 >0

使用以下命令运行 CenterPose 引擎生成

复制
已复制!
            

tao deploy centerpose gen_trt_engine -e /path/to/spec.yaml \ results_dir=/path/to/results \ gen_trt_engine.onnx_file=/path/to/onnx/file \ gen_trt_engine.trt_engine=/path/to/engine/file \ gen_trt_engine.tensorrt.data_type=<data_type>

必需参数

  • -e, --experiment_spec: 用于设置 TensorRT 引擎生成的实验 spec 文件。

可选参数

  • results_dir: 保存 JSON 状态日志文件的目录。

  • gen_trt_engine.onnx_file: 要转换的 .onnx 模型。

  • gen_trt_engine.trt_engine: 生成的引擎存储路径。

  • gen_trt_engine.tensorrt.data_type: 要导出的精度。

示例用法

以下是使用 gen_trt_engine 命令生成 FP16 TensorRT 引擎的示例

复制
已复制!
            

tao deploy centerpose gen_trt_engine -e $DEFAULT_SPEC gen_trt_engine.onnx_file=$ONNX_FILE \ gen_trt_engine.trt_engine=$ENGINE_FILE \ gen_trt_engine.tensorrt.data_type=FP16

您可以重复使用TAO 评估 spec 文件,以通过 TensorRT 引擎进行评估。以下是示例 spec 文件

复制
已复制!
            

evaluate: trt_engine: /path/to/engine/file opencv: False eval_num_symmetry: 1 results_dir: /path/to/save/results dataset: test_data: /path/to/testing/images/and/json/files batch_size: 2 workers: 4

使用以下命令运行 CenterPose 引擎评估

复制
已复制!
            

tao deploy centerpose evaluate -e /path/to/spec.yaml \ results_dir=/path/to/results \ evaluate.trt_engine=/path/to/engine/file

必需参数

  • -e, --experiment_spec: 用于评估的实验 spec 文件。这必须与 tao evaluate spec 文件相同。

可选参数

  • results_dir: 保存 JSON 状态日志文件和评估结果的目录。

  • evaluate.trt_engine: 用于评估的引擎文件。

示例用法

以下是使用 evaluate 命令通过 TensorRT 引擎运行评估的示例

复制
已复制!
            

tao deploy centerpose evaluate -e $DEFAULT_SPEC results_dir=$RESULTS_DIR \ evaluate.trt_engine=$ENGINE_FILE

您可以重复使用TAO 推理 spec 文件,以通过 TensorRT 引擎进行推理。以下是示例 spec 文件

复制
已复制!
            

inference: trt_engine: /path/to/engine/file visualization_threshold: 0.3 principle_point_x: 298.3 principle_point_y: 392.1 focal_length_x: 651.2 focal_length_y: 651.2 skew: 0.0 axis_size: 0.5 use_pnp: True save_json: True save_visualization: True opencv: True dataset: inference_data: /path/to/inference/files batch_size: 1 workers: 4

使用以下命令运行 CenterPose 引擎推理

复制
已复制!
            

tao deploy centerpose inference -e /path/to/spec.yaml \ results_dir=/path/to/results \ inference.trt_engine=/path/to/engine/file

必需参数

  • -e, --experiment_spec: 用于推理的实验 spec 文件。这应与 tao inference spec 文件相同。

可选参数

  • results_dir: 保存 JSON 状态日志文件和推理结果的目录。

  • inference.trt_engine: 用于推理的引擎文件。

示例用法

以下是使用 inference 命令通过 TensorRT 引擎运行推理的示例

复制
已复制!
            

tao deploy centerpose inference -e $DEFAULT_SPEC results_dir=$RESULTS_DIR \ evaluate.trt_engine=$ENGINE_FILE

可视化结果存储在 $RESULTS_DIR 中。

上一页 TAO Deploy 安装
下一页 使用 TAO Deploy 进行分类 (PyTorch)
© 版权所有 2024,NVIDIA。 上次更新时间:2024 年 10 月 15 日。