diff --git a/docs/guides/hyperparameter-tuning.md b/docs/guides/hyperparameter-tuning.md index e6a3f310bd..7cba64e6ad 100644 --- a/docs/guides/hyperparameter-tuning.md +++ b/docs/guides/hyperparameter-tuning.md @@ -23,7 +23,7 @@ Hyperparameters are high-level, structural settings for the algorithm. They are Hyperparameter Tuning Visual

-For a full list of augmentation hyperparameters used in YOLOv8 please refer to [https://docs.ultralytics.com/usage/cfg/#augmentation)(https://docs.ultralytics.com/usage/cfg/#augmentation). +For a full list of augmentation hyperparameters used in YOLOv8 please refer to [https://docs.ultralytics.com/usage/cfg/#augmentation](https://docs.ultralytics.com/usage/cfg/#augmentation). ### Genetic Evolution and Mutation @@ -203,4 +203,4 @@ The hyperparameter tuning process in Ultralytics YOLO is simplified yet powerful 2. [YOLOv5 Hyperparameter Evolution Guide](https://docs.ultralytics.com/yolov5/tutorials/hyperparameter_evolution/) 3. [Efficient Hyperparameter Tuning with Ray Tune and YOLOv8](https://docs.ultralytics.com/integrations/ray-tune/) -For deeper insights, you can explore the `Tuner` class source code and accompanying documentation. Should you have any questions, feature requests, or need further assistance, feel free to reach out to us on [GitHub](https://github.com/ultralytics/ultralytics/issues/new/choose) or [Discord](https://ultralytics.com/discord) \ No newline at end of file +For deeper insights, you can explore the `Tuner` class source code and accompanying documentation. Should you have any questions, feature requests, or need further assistance, feel free to reach out to us on [GitHub](https://github.com/ultralytics/ultralytics/issues/new/choose) or [Discord](https://ultralytics.com/discord). diff --git a/ultralytics/__init__.py b/ultralytics/__init__.py index 6bdf75c357..2ed7c080ed 100644 --- a/ultralytics/__init__.py +++ b/ultralytics/__init__.py @@ -1,6 +1,6 @@ # Ultralytics YOLO 🚀, AGPL-3.0 license -__version__ = '8.0.183' +__version__ = '8.0.184' from ultralytics.models import RTDETR, SAM, YOLO from ultralytics.models.fastsam import FastSAM diff --git a/ultralytics/engine/results.py b/ultralytics/engine/results.py index d6763ffba2..85c5406b89 100644 --- a/ultralytics/engine/results.py +++ b/ultralytics/engine/results.py @@ -13,7 +13,7 @@ import numpy as np import torch from ultralytics.data.augment import LetterBox -from ultralytics.utils import LOGGER, SimpleClass, deprecation_warn, ops +from ultralytics.utils import LOGGER, SimpleClass, ops from ultralytics.utils.plotting import Annotator, colors, save_one_box @@ -153,21 +153,20 @@ class Results(SimpleClass): return Results(orig_img=self.orig_img, path=self.path, names=self.names) def plot( - self, - conf=True, - line_width=None, - font_size=None, - font='Arial.ttf', - pil=False, - img=None, - im_gpu=None, - kpt_radius=5, - kpt_line=True, - labels=True, - boxes=True, - masks=True, - probs=True, - **kwargs # deprecated args TODO: remove support in 8.2 + self, + conf=True, + line_width=None, + font_size=None, + font='Arial.ttf', + pil=False, + img=None, + im_gpu=None, + kpt_radius=5, + kpt_line=True, + labels=True, + boxes=True, + masks=True, + probs=True, ): """ Plots the detection results on an input RGB image. Accepts a numpy array (cv2) or a PIL Image. @@ -207,17 +206,6 @@ class Results(SimpleClass): if img is None and isinstance(self.orig_img, torch.Tensor): img = (self.orig_img[0].detach().permute(1, 2, 0).contiguous() * 255).to(torch.uint8).cpu().numpy() - # Deprecation warn TODO: remove in 8.2 - if 'show_conf' in kwargs: - deprecation_warn('show_conf', 'conf') - conf = kwargs['show_conf'] - assert isinstance(conf, bool), '`show_conf` should be of boolean type, i.e, show_conf=True/False' - - if 'line_thickness' in kwargs: - deprecation_warn('line_thickness', 'line_width') - line_width = kwargs['line_thickness'] - assert isinstance(line_width, int), '`line_width` should be of int type, i.e, line_width=3' - names = self.names pred_boxes, show_boxes = self.boxes, boxes pred_masks, show_masks = self.masks, masks diff --git a/ultralytics/utils/plotting.py b/ultralytics/utils/plotting.py index 3d70d3c700..bfd2aaa1da 100644 --- a/ultralytics/utils/plotting.py +++ b/ultralytics/utils/plotting.py @@ -76,6 +76,7 @@ class Annotator: assert im.data.contiguous, 'Image not contiguous. Apply np.ascontiguousarray(im) to Annotator() input images.' non_ascii = not is_ascii(example) # non-latin labels, i.e. asian, arabic, cyrillic self.pil = pil or non_ascii + self.lw = line_width or max(round(sum(im.shape) / 2 * 0.003), 2) # line width if self.pil: # use PIL self.im = im if isinstance(im, Image.Image) else Image.fromarray(im) self.draw = ImageDraw.Draw(self.im) @@ -90,7 +91,8 @@ class Annotator: self.font.getsize = lambda x: self.font.getbbox(x)[2:4] # text width, height else: # use cv2 self.im = im - self.lw = line_width or max(round(sum(im.shape) / 2 * 0.003), 2) # line width + self.tf = max(self.lw - 1, 1) # font thickness + self.sf = self.lw / 3 # font scale # Pose self.skeleton = [[16, 14], [14, 12], [17, 15], [15, 13], [12, 13], [6, 12], [7, 13], [6, 7], [6, 8], [7, 9], [8, 10], [9, 11], [2, 3], [1, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7]] @@ -118,17 +120,16 @@ class Annotator: p1, p2 = (int(box[0]), int(box[1])), (int(box[2]), int(box[3])) cv2.rectangle(self.im, p1, p2, color, thickness=self.lw, lineType=cv2.LINE_AA) if label: - tf = max(self.lw - 1, 1) # font thickness - w, h = cv2.getTextSize(label, 0, fontScale=self.lw / 3, thickness=tf)[0] # text width, height + w, h = cv2.getTextSize(label, 0, fontScale=self.sf, thickness=self.tf)[0] # text width, height outside = p1[1] - h >= 3 p2 = p1[0] + w, p1[1] - h - 3 if outside else p1[1] + h + 3 cv2.rectangle(self.im, p1, p2, color, -1, cv2.LINE_AA) # filled cv2.putText(self.im, label, (p1[0], p1[1] - 2 if outside else p1[1] + h + 2), 0, - self.lw / 3, + self.sf, txt_color, - thickness=tf, + thickness=self.tf, lineType=cv2.LINE_AA) def masks(self, masks, colors, im_gpu, alpha=0.5, retina_masks=False): @@ -240,15 +241,13 @@ class Annotator: self.draw.text(xy, text, fill=txt_color, font=self.font) else: if box_style: - tf = max(self.lw - 1, 1) # font thickness - w, h = cv2.getTextSize(text, 0, fontScale=self.lw / 3, thickness=tf)[0] # text width, height + w, h = cv2.getTextSize(text, 0, fontScale=self.sf, thickness=self.tf)[0] # text width, height outside = xy[1] - h >= 3 p2 = xy[0] + w, xy[1] - h - 3 if outside else xy[1] + h + 3 cv2.rectangle(self.im, xy, p2, txt_color, -1, cv2.LINE_AA) # filled # Using `txt_color` for background and draw fg with white color txt_color = (255, 255, 255) - tf = max(self.lw - 1, 1) # font thickness - cv2.putText(self.im, text, xy, 0, self.lw / 3, txt_color, thickness=tf, lineType=cv2.LINE_AA) + cv2.putText(self.im, text, xy, 0, self.sf, txt_color, thickness=self.tf, lineType=cv2.LINE_AA) def fromarray(self, im): """Update self.im from a numpy array."""