From 1f8fc975d3f679035f55d9838158ab688e39a82e Mon Sep 17 00:00:00 2001 From: Dridi Yassin <73611344+yaslack@users.noreply.github.com> Date: Thu, 26 Jun 2025 02:54:30 +0200 Subject: [PATCH] =?UTF-8?q?Fix:=20Update=20torch.load=20to=20use=20weights?= =?UTF-8?q?=5Fonly=3DTrue=20to=20prevent=20security=20w=E2=80=A6=20(#2451)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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 --- whisper/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/whisper/__init__.py b/whisper/__init__.py index e210718..f284ec0 100644 --- a/whisper/__init__.py +++ b/whisper/__init__.py @@ -147,7 +147,8 @@ def load_model( with ( io.BytesIO(checkpoint_file) if in_memory else open(checkpoint_file, "rb") ) as fp: - checkpoint = torch.load(fp, map_location=device) + kwargs = {"weights_only": True} if torch.__version__ >= "1.13" else {} + checkpoint = torch.load(fp, map_location=device, **kwargs) del checkpoint_file dims = ModelDimensions(**checkpoint["dims"])