Build storage from a model directory containing `model.safetensors.index.json` or a single `model.safetensors` file.
(model_path: &Path)
| 246 | /// Build storage from a model directory containing `model.safetensors.index.json` |
| 247 | /// or a single `model.safetensors` file. |
| 248 | pub fn from_model_path(model_path: &Path) -> Result<Self> { |
| 249 | let index_path = model_path.join("model.safetensors.index.json"); |
| 250 | let single_path = model_path.join("model.safetensors"); |
| 251 | |
| 252 | if index_path.exists() { |
| 253 | Self::from_index_json(&index_path) |
| 254 | } else if single_path.exists() { |
| 255 | Self::from_single_file(&single_path) |
| 256 | } else { |
| 257 | bail!( |
| 258 | "no safetensors files found in {}", |
| 259 | model_path.display() |
| 260 | ) |
| 261 | } |
| 262 | } |
| 263 | |
| 264 | /// Build from a single safetensors file path (not a directory). |
| 265 | pub fn from_file(path: &Path) -> Result<Self> { |
nothing calls this directly
no outgoing calls
no test coverage detected