Fixed bugs when reading non-JIT model file

This commit is contained in:
yqiu1 2023-11-21 18:37:02 +08:00
parent a1d071733d
commit 3f3ffe0168
1 changed files with 1 additions and 0 deletions

View File

@ -133,6 +133,7 @@ def load(name: str, device: Union[str, torch.device] = "cuda" if torch.cuda.is_a
if jit:
warnings.warn(f"File {model_path} is not a JIT archive. Loading as a state dict instead")
jit = False
opened_file.seek(0) # If loading failed, reset file offset to the beginning
state_dict = torch.load(opened_file, map_location="cpu")
if not jit: