Skip to content

Commit 1f8fc97

Browse files
yaslackjongwook
andauthored
Fix: Update torch.load to use weights_only=True to prevent security w… (#2451)
* Fix: Update torch.load to use weights_only=True to prevent security warning * Update __init__.py * Update __init__.py --------- Co-authored-by: Jong Wook Kim <[email protected]>
1 parent 679ae1d commit 1f8fc97

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

whisper/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,8 @@ def load_model(
147147
with (
148148
io.BytesIO(checkpoint_file) if in_memory else open(checkpoint_file, "rb")
149149
) as fp:
150-
checkpoint = torch.load(fp, map_location=device)
150+
kwargs = {"weights_only": True} if torch.__version__ >= "1.13" else {}
151+
checkpoint = torch.load(fp, map_location=device, **kwargs)
151152
del checkpoint_file
152153

153154
dims = ModelDimensions(**checkpoint["dims"])

0 commit comments

Comments
 (0)