FIx downstream impact by the replacement of torch.load in ultralytics package (#13623)
* Update torch_load * Auto-format by https://ultralytics.com/actions --------- Co-authored-by: UltralyticsAssistant <web@ultralytics.com>
This commit is contained in:
1 parent
79c4c31d16
commit
2540fd4c1c
9 files changed
+20
-12
No files matched your search
+2
-1
@@ -44,6 +44,7 @@ except (ImportError, AssertionError):
|
||||
import ultralytics
|
||||
|
||||
from ultralytics.utils.checks import check_requirements
|
||||
from ultralytics.utils.patches import torch_load
|
||||
|
||||
from utils import TryExcept, emojis
|
||||
from utils.downloads import curl_download, gsutil_getsize
|
||||
@@ -1127,7 +1128,7 @@ def strip_optimizer(f="best.pt", s=""):
|
||||
|
||||
Example: from utils.general import *; strip_optimizer()
|
||||
"""
|
||||
x = torch.load(f, map_location=torch.device("cpu"))
|
||||
x = torch_load(f, map_location=torch.device("cpu"))
|
||||
if x.get("ema"):
|
||||
x["model"] = x["ema"] # replace model with ema
|
||||
for k in "optimizer", "best_fitness", "ema", "updates": # keys
|
||||
|
||||
Reference in new issue
Block a user