Fix torch.load

Weights only load failed. Changed torch.load(file, map_location=cpu) to ckpt = torch.load(file, map_location=cpu, weights_only=False). Resolves #523. Credit goes to @allansdefreitas.
This commit is contained in:
Defne Dilbaz 2025-04-02 16:37:09 -04:00 committed by GitHub
parent 453c6e38a5
commit 8b84ade39b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -730,7 +730,7 @@ def torch_safe_load(weight):
"ultralytics.yolo.data": "ultralytics.data",
}
): # for legacy 8.0 Classify and Pose models
ckpt = torch.load(file, map_location="cpu")
ckpt = torch.load(file, map_location="cpu", weights_only=False)
except ModuleNotFoundError as e: # e.name is missing module name
if e.name == "models":