From d8c36c91f8dc0d6197aea617ce33e7aaaad2b54b Mon Sep 17 00:00:00 2001 From: ubik2 Date: Mon, 8 May 2023 00:56:12 -0700 Subject: [PATCH] Check for safetensors files first, and only use PyTorch versions when safetensors aren't available --- convert.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/convert.py b/convert.py index 75eeb6125..c9885eaa4 100644 --- a/convert.py +++ b/convert.py @@ -1035,11 +1035,11 @@ def load_some_model(path: Path) -> ModelPlus: '''Load a model of any supported format.''' # Be extra-friendly and accept either a file or a directory: if path.is_dir(): - globs = ["consolidated.00.pth", "pytorch_model-00001-of-*.bin", "*.pt"] - files = [file for glob in globs for file in path.glob(glob)] + # Check if it's a set of safetensors files first + files = list(path.glob("model-00001-of-*.safetensors")) if not files: - # Check if it's a set of safetensors files - globs = ["model-00001-of-*.safetensors"] + # Try the PyTorch patterns too, with lower priority + globs = ["consolidated.00.pth", "pytorch_model-00001-of-*.bin", "*.pt"] files = [file for glob in globs for file in path.glob(glob)] if not files: # Try GGML too, but with lower priority, since if both a non-GGML