extract_safetensors_model

onnx_safetensors.extract_safetensors_model(safetensors_model_path, output_path=None)[source]

Unpack an ONNX model stored in a safetensors file.

This function will extract the onnx model from a safetensors file created by save_safetensors_model.

Added in version 1.5.0: Added the function.

Parameters:
  • safetensors_model_path (str | PathLike) – Path to the safetensors model file.

  • output_path (str | PathLike | None) – If provided, the extracted ONNX model (that references the safetensors file as external data) will be saved to this path.

Returns:

The extracted ONNX model.

Return type:

Model