Skip to content

Commit 89b5387

Browse files
JPPhotopsychedelicious
authored andcommitted
Update model_util.py
1 parent 2d334c8 commit 89b5387

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

invokeai/backend/model_manager/util/model_util.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,15 @@ def read_checkpoint_meta(path: Union[str, Path], scan: bool = True) -> Dict[str,
5252
except Exception:
5353
# TODO: create issue for support "meta"?
5454
checkpoint = safetensors.torch.load_file(path, device="cpu")
55+
elif str(path).endswith(".gguf"):
56+
# The GGUF reader used here uses numpy memmap, so these tensors are not loaded into memory during this function
57+
checkpoint = gguf_sd_loader(Path(path), compute_dtype=torch.float32)
5558
else:
5659
if scan:
5760
scan_result = scan_file_path(path)
5861
if scan_result.infected_files != 0 or scan_result.scan_err:
5962
raise Exception(f'The model file "{path}" is potentially infected by malware. Aborting import.')
60-
if str(path).endswith(".gguf"):
61-
# The GGUF reader used here uses numpy memmap, so these tensors are not loaded into memory during this function
62-
checkpoint = gguf_sd_loader(Path(path), compute_dtype=torch.float32)
63-
else:
64-
checkpoint = torch.load(path, map_location=torch.device("meta"))
63+
checkpoint = torch.load(path, map_location=torch.device("meta"))
6564
return checkpoint
6665

6766

0 commit comments

Comments
 (0)