
Convert Installed Models to 16-Bit Half Precision (FP16)
Source:R/utils_yolo_quantize.R
model_to_fp16.Rdmodel_to_fp16() converts installed or custom models to 16-bit half precision (FP16).
This reduces model disk footprint and GPU VRAM consumption by ~50% with practically
identical predictions.
Speed depends on the hardware. FP16 is expected to be faster only on GPUs with
Tensor Cores (NVIDIA RTX and data-center GPUs). On GPUs without Tensor Cores (e.g. GTX
10xx/16xx) and on CPU, FP16 models are usually equal or slower than FP32. Converted
models are saved alongside the originals (FP32 files are never removed), so you can
benchmark both and choose. See yolo_export_fp16() for details and a benchmark example.
When model = NULL (default), model_to_fp16() scans pliman_model_dir() for .pt
and unquantized .onnx models and converts them to _fp16.onnx.
Existing FP16 models are skipped unless overwrite = TRUE.
Usage
model_to_fp16(
model = NULL,
dir = pliman_model_dir(),
overwrite = FALSE,
verbose = TRUE
)
models_to_fp16(
model = NULL,
dir = pliman_model_dir(),
overwrite = FALSE,
verbose = TRUE
)Arguments
- model
Optional character vector of model name(s) or file path(s) to convert. If
NULL(default), all unconverted models indirare processed.- dir
Directory where installed models are located. Defaults to
pliman_model_dir().- overwrite
Logical. If
TRUE, re-converts models even if an_fp16.onnxversion already exists. Defaults toFALSE.- verbose
Logical. Show progress messages and compression summary. Defaults to
TRUE.