From 0c6e1e16bd0778ac7a6f86eb794e3c33257e2028 Mon Sep 17 00:00:00 2001 From: Josh Jarabek <84693614+JoshJarabek7@users.noreply.github.com> Date: Thu, 22 Aug 2024 07:08:32 -0500 Subject: [PATCH] `ultralytics 8.2.80` add PIL type hints to `model()` (#15719) Co-authored-by: Glenn Jocher Co-authored-by: UltralyticsAssistant --- ultralytics/__init__.py | 2 +- ultralytics/engine/model.py | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/ultralytics/__init__.py b/ultralytics/__init__.py index 93ca50b1a..a03cb559e 100644 --- a/ultralytics/__init__.py +++ b/ultralytics/__init__.py @@ -1,6 +1,6 @@ # Ultralytics YOLO 🚀, AGPL-3.0 license -__version__ = "8.2.79" +__version__ = "8.2.80" import os diff --git a/ultralytics/engine/model.py b/ultralytics/engine/model.py index 7e215319f..ddbfa9de5 100644 --- a/ultralytics/engine/model.py +++ b/ultralytics/engine/model.py @@ -6,6 +6,7 @@ from typing import List, Union import numpy as np import torch +from PIL import Image from ultralytics.cfg import TASK2DATA, get_cfg, get_save_dir from ultralytics.engine.results import Results @@ -143,7 +144,7 @@ class Model(nn.Module): def __call__( self, - source: Union[str, Path, int, list, tuple, np.ndarray, torch.Tensor] = None, + source: Union[str, Path, int, Image.Image, list, tuple, np.ndarray, torch.Tensor] = None, stream: bool = False, **kwargs, ) -> list: @@ -504,7 +505,7 @@ class Model(nn.Module): def predict( self, - source: Union[str, Path, int, list, tuple, np.ndarray, torch.Tensor] = None, + source: Union[str, Path, int, Image.Image, list, tuple, np.ndarray, torch.Tensor] = None, stream: bool = False, predictor=None, **kwargs, @@ -517,7 +518,7 @@ class Model(nn.Module): types of image sources and can operate in a streaming mode. Args: - source (str | Path | int | List[str] | List[Path] | List[int] | np.ndarray | torch.Tensor): The source + source (str | Path | int | PIL.Image | np.ndarray | torch.Tensor | List | Tuple): The source of the image(s) to make predictions on. Accepts various types including file paths, URLs, PIL images, numpy arrays, and torch tensors. stream (bool): If True, treats the input source as a continuous stream for predictions.