From e60992214c91d3ba169965053af69d6eb233b45e Mon Sep 17 00:00:00 2001 From: Mohammed Yasin <32206511+Y-T-G@users.noreply.github.com> Date: Fri, 29 Nov 2024 06:08:28 +0800 Subject: [PATCH] `ultralytics 8.3.39` fix classification validation loss scaling (#17851) Co-authored-by: Glenn Jocher --- ultralytics/__init__.py | 2 +- ultralytics/models/yolo/classify/predict.py | 2 +- ultralytics/nn/modules/head.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ultralytics/__init__.py b/ultralytics/__init__.py index fe22ab07a..7b73169de 100644 --- a/ultralytics/__init__.py +++ b/ultralytics/__init__.py @@ -1,6 +1,6 @@ # Ultralytics YOLO 🚀, AGPL-3.0 license -__version__ = "8.3.38" +__version__ = "8.3.39" import os diff --git a/ultralytics/models/yolo/classify/predict.py b/ultralytics/models/yolo/classify/predict.py index 596931a17..b75a19498 100644 --- a/ultralytics/models/yolo/classify/predict.py +++ b/ultralytics/models/yolo/classify/predict.py @@ -54,6 +54,6 @@ class ClassificationPredictor(BasePredictor): orig_imgs = ops.convert_torch2numpy_batch(orig_imgs) return [ - Results(orig_img, path=img_path, names=self.model.names, probs=pred) + Results(orig_img, path=img_path, names=self.model.names, probs=pred.softmax(0)) for pred, orig_img, img_path in zip(preds, orig_imgs, self.batch[0]) ] diff --git a/ultralytics/nn/modules/head.py b/ultralytics/nn/modules/head.py index 29a1953e4..25964ac2e 100644 --- a/ultralytics/nn/modules/head.py +++ b/ultralytics/nn/modules/head.py @@ -296,7 +296,7 @@ class Classify(nn.Module): if isinstance(x, list): x = torch.cat(x, 1) x = self.linear(self.drop(self.pool(self.conv(x)).flatten(1))) - return x if self.training else x.softmax(1) + return x class WorldDetect(Detect):