New smart_inference_mode() conditional decorator (#8957)

New smart_inference_mode()
This commit is contained in:
Glenn Jocher authored and GitHub committed 2022-08-13 20:38:51 +02:00
1 parent 6aed0a7c00
commit dc38cd03f4
6 files changed
+26 -18

No files matched your search

+2 -2
View File
@@ -25,7 +25,7 @@ from utils.dataloaders import exif_transpose, letterbox
from utils.general import (LOGGER, check_requirements, check_suffix, check_version, colorstr, increment_path,
make_divisible, non_max_suppression, scale_coords, xywh2xyxy, xyxy2xywh)
from utils.plots import Annotator, colors, save_one_box
from utils.torch_utils import copy_attr, time_sync
from utils.torch_utils import copy_attr, smart_inference_mode, time_sync
def autopad(k, p=None): # kernel, padding
@@ -578,7 +578,7 @@ class AutoShape(nn.Module):
m.anchor_grid = list(map(fn, m.anchor_grid))
return self
@torch.no_grad()
@smart_inference_mode()
def forward(self, imgs, size=640, augment=False, profile=False):
# Inference from various sources. For height=640, width=1280, RGB images example inputs are:
# file: imgs = 'data/images/zidane.jpg' # str or PosixPath