diff --git a/paddlehub/vision/utils.py b/paddlehub/vision/utils.py index 826b6a281246c1ed6c7cc4b7f42f35bd224ac204..7d1e216d4bbd1de573d52b705c91482e8ca3471e 100644 --- a/paddlehub/vision/utils.py +++ b/paddlehub/vision/utils.py @@ -19,7 +19,6 @@ import cv2 import paddle import PIL import numpy as np -import matplotlib as plt import paddle.nn.functional as F from scipy.sparse import csr_matrix @@ -107,6 +106,10 @@ def draw_boxes_on_image(image_path: str, score_thresh: float = 0.5, save_path: str = 'result'): """Draw boxes on images.""" + # On windows, importing paddlenlp and matplotlib at the same time will cause python + # to fail to catch C++ exceptions. Delay matplotlib to avoid this problem. + import matplotlib as plt + image = np.array(PIL.Image.open(image_path)) plt.figure() _, ax = plt.subplots(1)