
Convert Installed ONNX Models to 8-Bit Precision (INT8)
Source:R/utils_yolo_quantize.R
model_to_int8.Rdmodel_to_int8() converts installed or custom ONNX neural network models to 8-bit integer
(INT8) precision. Dynamic quantization reduces model disk size by up to 75% and accelerates
CPU inference by 2–3x with virtually no loss in detection or segmentation accuracy.
When model = NULL (default), model_to_int8() scans the pliman model directory
(pliman_model_dir()) and converts all installed FP32 .onnx models into _int8.onnx models.
Existing INT8 models are skipped unless overwrite = TRUE.
Usage
model_to_int8(
model = NULL,
dir = pliman_model_dir(),
weight_type = c("QUInt8", "QInt8"),
overwrite = FALSE,
verbose = TRUE
)
models_to_int8(
model = NULL,
dir = pliman_model_dir(),
weight_type = c("QUInt8", "QInt8"),
overwrite = FALSE,
verbose = TRUE
)Arguments
- model
Optional character vector of model name(s) or file path(s) to quantize. If
NULL(default), all unquantized.onnxmodels indirare converted.- dir
Directory where installed models are located. Defaults to
pliman_model_dir().- weight_type
Precision type:
"QUInt8"(unsigned 8-bit, default) or"QInt8"(signed 8-bit).- overwrite
Logical. If
TRUE, re-quantizes models even if an_int8.onnxversion already exists. Defaults toFALSE.- verbose
Logical. Show progress messages and compression summary. Defaults to
TRUE.