New YOLOv8 Results() class for prediction outputs (#314)

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
Co-authored-by: Laughing-q <1185102784@qq.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Laughing <61612323+Laughing-q@users.noreply.github.com>
Co-authored-by: Viet Nhat Thai <60825385+vietnhatthai@users.noreply.github.com>
Co-authored-by: Paula Derrenger <107626595+pderrenger@users.noreply.github.com>
This commit is contained in:
Ayush Chaurasia 2023-01-17 19:02:34 +05:30 committed by GitHub
parent 0cb87f7dd3
commit c6985da9de
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
32 changed files with 813 additions and 259 deletions

View file

@ -65,6 +65,7 @@ class AutoBackend(nn.Module):
model = weights.to(device)
model = model.fuse() if fuse else model
names = model.module.names if hasattr(model, 'module') else model.names # get class names
stride = max(int(model.stride.max()), 32) # model stride
model.half() if fp16 else model.float()
self.model = model # explicitly assign for to(), cpu(), cuda(), half()
pt = True
@ -236,7 +237,7 @@ class AutoBackend(nn.Module):
Runs inference on the YOLOv8 MultiBackend model.
Args:
im (torch.tensor): The image tensor to perform inference on.
im (torch.Tensor): The image tensor to perform inference on.
augment (bool): whether to perform data augmentation during inference, defaults to False
visualize (bool): whether to visualize the output predictions, defaults to False
@ -328,10 +329,10 @@ class AutoBackend(nn.Module):
Convert a numpy array to a tensor.
Args:
x (numpy.ndarray): The array to be converted.
x (np.ndarray): The array to be converted.
Returns:
(torch.tensor): The converted tensor
(torch.Tensor): The converted tensor
"""
return torch.from_numpy(x).to(self.device) if isinstance(x, np.ndarray) else x