allow quantized model to be loaded from model dir (#760)

This commit is contained in:
catalpaaa 2023-04-04 19:19:38 -07:00 committed by GitHub
parent ae1fe45bc0
commit 4ab679480e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 5 deletions

View file

@ -74,7 +74,7 @@ def load_quantized(model_name):
exit()
# Now we are going to try to locate the quantized model file.
path_to_model = Path(f'models/{model_name}')
path_to_model = Path(f'{shared.args.model_dir}/{model_name}')
found_pts = list(path_to_model.glob("*.pt"))
found_safetensors = list(path_to_model.glob("*.safetensors"))
pt_path = None
@ -95,8 +95,8 @@ def load_quantized(model_name):
else:
pt_model = f'{model_name}-{shared.args.wbits}bit'
# Try to find the .safetensors or .pt both in models/ and in the subfolder
for path in [Path(p+ext) for ext in ['.safetensors', '.pt'] for p in [f"models/{pt_model}", f"{path_to_model}/{pt_model}"]]:
# Try to find the .safetensors or .pt both in the model dir and in the subfolder
for path in [Path(p+ext) for ext in ['.safetensors', '.pt'] for p in [f"{shared.args.model_dir}/{pt_model}", f"{path_to_model}/{pt_model}"]]:
if path.exists():
print(f"Found {path}")
pt_path = path