ultralytics 8.0.188 fix .grad attribute leaf Tensor Warning (#5094)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
parent
f2ed207571
commit
19c3314e68
11 changed files with 78 additions and 41 deletions
|
|
@ -39,6 +39,7 @@ def check_class_names(names):
|
|||
|
||||
class AutoBackend(nn.Module):
|
||||
|
||||
@torch.no_grad()
|
||||
def __init__(self,
|
||||
weights='yolov8n.pt',
|
||||
device=torch.device('cpu'),
|
||||
|
|
@ -309,6 +310,11 @@ class AutoBackend(nn.Module):
|
|||
names = self._apply_default_class_names(data)
|
||||
names = check_class_names(names)
|
||||
|
||||
# Disable gradients
|
||||
if pt:
|
||||
for p in model.parameters():
|
||||
p.requires_grad = False
|
||||
|
||||
self.__dict__.update(locals()) # assign all variables to self
|
||||
|
||||
def forward(self, im, augment=False, visualize=False):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue