Skip to contents

model_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 in dir are processed.

dir

Directory where installed models are located. Defaults to pliman_model_dir().

overwrite

Logical. If TRUE, re-converts models even if an _fp16.onnx version already exists. Defaults to FALSE.

verbose

Logical. Show progress messages and compression summary. Defaults to TRUE.

Value

A data.frame of class pliman_fp16_summary listing each model, original size, FP16 size, reduction percentage, and conversion status.

Examples

if (FALSE) { # interactive()
library(pliman)

# Convert all installed models to FP16
summary <- model_to_fp16()
print(summary)
}