159
-160
-161
-162
-163
+ | def __init__(self, *args, **kwargs):
- """
- Initializes a custom TQDM progress bar.
-
- This class extends the original tqdm class to provide customized behavior for Ultralytics projects.
-
- Args:
- *args (Any): Variable length argument list to be passed to the original tqdm constructor.
- **kwargs (Any): Arbitrary keyword arguments to be passed to the original tqdm constructor.
+181
+182
+183
+184
+185
+186
| def __init__(self, *args, **kwargs):
+ """
+ Initializes a custom TQDM progress bar.
+
+ This class extends the original tqdm class to provide customized behavior for Ultralytics projects.
- Notes:
- - The progress bar is disabled if VERBOSE is False or if 'disable' is explicitly set to True in kwargs.
- - The default bar format is set to TQDM_BAR_FORMAT unless overridden in kwargs.
+ Args:
+ *args (Any): Variable length argument list to be passed to the original tqdm constructor.
+ **kwargs (Any): Arbitrary keyword arguments to be passed to the original tqdm constructor.
- Examples:
- >>> from ultralytics.utils import TQDM
- >>> for i in TQDM(range(100)):
- ... # Your code here
- ... pass
- """
- kwargs["disable"] = not VERBOSE or kwargs.get("disable", False) # logical 'and' with default value if passed
- kwargs.setdefault("bar_format", TQDM_BAR_FORMAT) # override default value if passed
- super().__init__(*args, **kwargs)
+ Notes:
+ - The progress bar is disabled if VERBOSE is False or if 'disable' is explicitly set to True in kwargs.
+ - The default bar format is set to TQDM_BAR_FORMAT unless overridden in kwargs.
+
+ Examples:
+ >>> from ultralytics.utils import TQDM
+ >>> for i in TQDM(range(100)):
+ ... # Your code here
+ ... pass
+ """
+ warnings.filterwarnings("ignore", category=tqdm.TqdmExperimentalWarning) # suppress tqdm.rich warning
+ kwargs["disable"] = not VERBOSE or kwargs.get("disable", False)
+ kwargs.setdefault("bar_format", TQDM_BAR_FORMAT) # override default value if passed
+ super().__init__(*args, **kwargs)
|
@@ -2223,13 +2225,13 @@
Custom attribute access error message with helpful information.
Source code in ultralytics/utils/__init__.py
- | def __getattr__(self, attr):
- """Custom attribute access error message with helpful information."""
- name = self.__class__.__name__
- raise AttributeError(f"'{name}' object has no attribute '{attr}'. See valid attributes below.\n{self.__doc__}")
+ | def __getattr__(self, attr):
+ """Custom attribute access error message with helpful information."""
+ name = self.__class__.__name__
+ raise AttributeError(f"'{name}' object has no attribute '{attr}'. See valid attributes below.\n{self.__doc__}")
|
@@ -2244,11 +2246,11 @@
Return a machine-readable string representation of the object.
Source code in ultralytics/utils/__init__.py
- | def __repr__(self):
- """Return a machine-readable string representation of the object."""
- return self.__str__()
+ | def __repr__(self):
+ """Return a machine-readable string representation of the object."""
+ return self.__str__()
|
@@ -2263,31 +2265,31 @@
Return a human-readable string representation of the object.
Source code in ultralytics/utils/__init__.py
-214
-215
-216
-217
-218
-219
+ | def __str__(self):
- """Return a human-readable string representation of the object."""
- attr = []
- for a in dir(self):
- v = getattr(self, a)
- if not callable(v) and not a.startswith("_"):
- if isinstance(v, SimpleClass):
- # Display only the module and class name for subclasses
- s = f"{a}: {v.__module__}.{v.__class__.__name__} object"
- else:
- s = f"{a}: {repr(v)}"
- attr.append(s)
- return f"{self.__module__}.{self.__class__.__name__} object with attributes:\n\n" + "\n".join(attr)
+226
+227
+228
+229
+230
+231
| def __str__(self):
+ """Return a human-readable string representation of the object."""
+ attr = []
+ for a in dir(self):
+ v = getattr(self, a)
+ if not callable(v) and not a.startswith("_"):
+ if isinstance(v, SimpleClass):
+ # Display only the module and class name for subclasses
+ s = f"{a}: {v.__module__}.{v.__class__.__name__} object"
+ else:
+ s = f"{a}: {repr(v)}"
+ attr.append(s)
+ return f"{self.__module__}.{self.__class__.__name__} object with attributes:\n\n" + "\n".join(attr)
|
@@ -2381,27 +2383,27 @@ |
|
|