Skip to content

Reference for ultralytics/utils/errors.py

Note

This file is available at https://github.com/ultralytics/ultralytics/blob/main/ultralytics/utils/errors.py. If you spot a problem please help fix it by contributing a Pull Request 🛠️. Thank you 🙏!


ultralytics.utils.errors.HUBModelError

HUBModelError(message='Model not found. Please check model URL and try again.')

Bases: Exception

Exception raised when a model cannot be found or retrieved from Ultralytics HUB.

This custom exception is used specifically for handling errors related to model fetching in Ultralytics YOLO. The error message is processed to include emojis for better user experience.

Attributes:

Name Type Description
message str

The error message displayed when the exception is raised.

Methods:

Name Description

Examples:

>>> try:
>>> # Code that might fail to find a model
>>>     raise HUBModelError("Custom model not found message")
>>> except HUBModelError as e:
>>>     print(e)  # Displays the emoji-enhanced error message

This exception is raised when a requested model is not found or cannot be retrieved from Ultralytics HUB. The message is processed to include emojis for better user experience.

Parameters:

Name Type Description Default
message str

The error message to display when the exception is raised.

'Model not found. Please check model URL and try again.'

Examples:

>>> try:
...     raise HUBModelError("Custom model error message")
... except HUBModelError as e:
...     print(e)
Source code in ultralytics/utils/errors.py
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
def __init__(self, message="Model not found. Please check model URL and try again."):
    """
    Initialize a HUBModelError exception.

    This exception is raised when a requested model is not found or cannot be retrieved from Ultralytics HUB.
    The message is processed to include emojis for better user experience.

    Args:
        message (str, optional): The error message to display when the exception is raised.

    Examples:
        >>> try:
        ...     raise HUBModelError("Custom model error message")
        ... except HUBModelError as e:
        ...     print(e)
    """
    super().__init__(emojis(message))





📅 Created 1 year ago ✏️ Updated 7 months ago