Python function
weights_format
weights_format()โ
max.graph.weights.weights_format(weight_paths)
Detect the format of weight files based on their extensions.
This function examines the file extensions of all provided paths to determine the weight format. All files must have the same format; mixed formats are not supported.
from pathlib import Path
paths = [Path("model-00001.safetensors"), Path("model-00002.safetensors")]
format = weights_format(paths)
print(format) # WeightsFormat.safetensors-
Parameters:
-
weight_paths (list[Path]) โ List of file paths containing model weights. All files must have the same extension/format.
-
Returns:
-
The detected WeightsFormat enum value.
-
Raises:
-
ValueError โ If weight_paths is empty, contains mixed formats, or has unsupported file extensions.
-
Return type:
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!