Release 8.0.5 PR (#279)

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: Izam Mohammed <106471909+izam-mohammed@users.noreply.github.com>
Co-authored-by: Yue WANG 王跃 <92371174+yuewangg@users.noreply.github.com>
Co-authored-by: Thibaut Lucas <thibautlucas13@gmail.com>
This commit is contained in:
Laughing
2023-01-13 00:09:26 +08:00
committed by GitHub
parent 9552827157
commit c42e44a021
28 changed files with 940 additions and 311 deletions

View File

@ -24,7 +24,7 @@ class DetectionValidator(BaseValidator):
self.data_dict = yaml_load(check_file(self.args.data), append_filename=True) if self.args.data else None
self.is_coco = False
self.class_map = None
self.metrics = DetMetrics(save_dir=self.save_dir, plot=self.args.plots)
self.metrics = DetMetrics(save_dir=self.save_dir)
self.iouv = torch.linspace(0.5, 0.95, 10) # iou vector for mAP@0.5:0.95
self.niou = self.iouv.numel()
@ -34,8 +34,7 @@ class DetectionValidator(BaseValidator):
for k in ["batch_idx", "cls", "bboxes"]:
batch[k] = batch[k].to(self.device)
nb, _, height, width = batch["img"].shape
batch["bboxes"] *= torch.tensor((width, height, width, height), device=self.device) # to pixels
nb = len(batch["img"])
self.lb = [torch.cat([batch["cls"], batch["bboxes"]], dim=-1)[batch["batch_idx"] == i]
for i in range(nb)] if self.args.save_hybrid else [] # for autolabelling
@ -50,6 +49,7 @@ class DetectionValidator(BaseValidator):
self.nc = head.nc
self.names = model.names
self.metrics.names = self.names
self.metrics.plot = self.args.plots
self.confusion_matrix = ConfusionMatrix(nc=self.nc)
self.seen = 0
self.jdict = []
@ -95,7 +95,9 @@ class DetectionValidator(BaseValidator):
# Evaluate
if nl:
tbox = ops.xywh2xyxy(bbox) # target boxes
height, width = batch["img"].shape[2:]
tbox = ops.xywh2xyxy(bbox) * torch.tensor(
(width, height, width, height), device=self.device) # target boxes
ops.scale_boxes(batch["img"][si].shape[1:], tbox, shape,
ratio_pad=batch["ratio_pad"][si]) # native-space labels
labelsn = torch.cat((cls, tbox), 1) # native-space labels