Przeglądaj źródła

set matplotlib.backends to be Agg for the first time

FlyingQianMM 4 lat temu
rodzic
commit
53c62c3904
1 zmienionych plików z 8 dodań i 1 usunięć
  1. 8 1
      paddlex/__init__.py

+ 8 - 1
paddlex/__init__.py

@@ -34,11 +34,18 @@ if version[0] == '1':
             format(__version__))
     import paddlehub as hub
     if hub.__version__.strip().split('.')[0] > '1':
-        raise Exception("Try to reinstall Paddlehub by 'pip install paddlehub==1.8.2' while paddlepaddle < 2.0")
+        raise Exception(
+            "Try to reinstall Paddlehub by 'pip install paddlehub==1.8.2' while paddlepaddle < 2.0"
+        )
 
 if hasattr(paddle, 'enable_static'):
     paddle.enable_static()
 
+# matplotlib.use() must be called *before* pylab, matplotlib.pyplot,
+# or matplotlib.backends is imported for the first time
+import matplotlib
+matplotlib.use('Agg')
+
 from .utils.utils import get_environ_info
 from . import cv
 from . import det