From 391b7e67cfe551578c2bf3336925e3296528d2d7 Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Mon, 10 Jul 2023 14:52:59 +0200 Subject: [PATCH] Filter `matplotlib>=3.7.2` tight layout warning (#3614) --- ultralytics/yolo/engine/exporter.py | 2 +- ultralytics/yolo/utils/plotting.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ultralytics/yolo/engine/exporter.py b/ultralytics/yolo/engine/exporter.py index c54cf33..5d23627 100644 --- a/ultralytics/yolo/engine/exporter.py +++ b/ultralytics/yolo/engine/exporter.py @@ -201,7 +201,7 @@ class Exporter: if self.args.half and (engine or onnx) and self.device.type != 'cpu': im, model = im.half(), model.half() # to FP16 - # Warnings + # Filter warnings warnings.filterwarnings('ignore', category=torch.jit.TracerWarning) # suppress TracerWarning warnings.filterwarnings('ignore', category=UserWarning) # suppress shape prim::Constant missing ONNX warning warnings.filterwarnings('ignore', category=DeprecationWarning) # suppress CoreML np.bool deprecation warning diff --git a/ultralytics/yolo/utils/plotting.py b/ultralytics/yolo/utils/plotting.py index 9061ca1..8932062 100644 --- a/ultralytics/yolo/utils/plotting.py +++ b/ultralytics/yolo/utils/plotting.py @@ -2,6 +2,7 @@ import contextlib import math +import warnings from pathlib import Path import cv2 @@ -233,6 +234,9 @@ def plot_labels(boxes, cls, names=(), save_dir=Path(''), on_plot=None): import pandas as pd import seaborn as sn + # Filter matplotlib>=3.7.2 warning + warnings.filterwarnings('ignore', category=UserWarning, message='The figure layout has changed to tight') + # Plot dataset labels LOGGER.info(f"Plotting labels to {save_dir / 'labels.jpg'}... ") b = boxes.transpose() # classes, boxes