Segmentation support & other enchancements (#40)

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>
This commit is contained in:
Ayush Chaurasia
2022-11-08 20:57:57 +05:30
committed by GitHub
parent c617ee1c79
commit f56c9bcc26
17 changed files with 1320 additions and 47 deletions

View File

@ -5,10 +5,16 @@ from ultralytics.yolo.engine.validator import BaseValidator
class ClassificationValidator(BaseValidator):
def init_metrics(self):
def init_metrics(self, model):
self.correct = torch.tensor([])
def update_metrics(self, preds, targets):
def preprocess_batch(self, batch):
batch["img"] = batch["img"].to(self.device)
batch["cls"] = batch["cls"].to(self.device)
return batch
def update_metrics(self, preds, batch):
targets = batch["cls"]
correct_in_batch = (targets[:, None] == preds).float()
self.correct = torch.cat((self.correct, correct_in_batch))