-
Notifications
You must be signed in to change notification settings - Fork 762
Fix compatibility with PyTorch 2.6+ and matplotlib >=3.6 #283
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,7 @@ scipy>=1.4.1 | |
| torch>=1.7.0 | ||
| torchvision>=0.8.1 | ||
| tqdm>=4.64.0 | ||
| psutil | ||
|
|
||
| pandas>=1.1.4 | ||
| seaborn>=0.11.0 | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,7 @@ | |
|
|
||
| import torch | ||
| import torch.nn as nn | ||
| import pickle | ||
|
|
||
| from ultralytics.nn.modules import (AIFI, C1, C2, C3, C3TR, SPP, SPPF, Bottleneck, BottleneckCSP, C2f, C3Ghost, C3x, | ||
| Classify, Concat, Conv, Conv2, ConvTranspose, Detect, DWConv, DWConvTranspose2d, | ||
|
|
@@ -515,7 +516,7 @@ def torch_safe_load(weight): | |
| check_suffix(file=weight, suffix='.pt') | ||
| file = attempt_download_asset(weight) # search online if missing locally | ||
| try: | ||
| return torch.load(file, map_location='cpu'), file # load | ||
| return torch.load(file, map_location='cpu', weights_only=True), file # load | ||
| except ModuleNotFoundError as e: # e.name is missing module name | ||
| if e.name == 'models': | ||
| raise TypeError( | ||
|
|
@@ -530,7 +531,12 @@ def torch_safe_load(weight): | |
| f"run a command with an official YOLOv8 model, i.e. 'yolo predict model=yolov8n.pt'") | ||
| check_requirements(e.name) # install missing module | ||
|
|
||
| return torch.load(file, map_location='cpu'), file # load | ||
| return torch.load(file, map_location='cpu', weights_only=True), file # load | ||
| except (pickle.UnpicklingError, RuntimeError) as e: | ||
| LOGGER.warning(f"WARNING ⚠️ {weight} requires non-safe pickle loading. " | ||
| f"Falling back to weights_only=False. " | ||
| f"Only load weights from trusted sources.") | ||
| return torch.load(file, map_location='cpu', weights_only=False), file # load | ||
|
||
|
|
||
|
|
||
| def attempt_load_weights(weights, device=None, inplace=True, fuse=False): | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.