Skip to content

Commit 985bff2

Browse files
committed
1 parent 66e2635 commit 985bff2

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

‎labelme/cli/json_to_dataset.py‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44
import os.path as osp
55
import warnings
66

7-
import matplotlib
8-
matplotlib.use('Agg')
9-
107
import numpy as np
118
import PIL.Image
129
import yaml

‎labelme/utils.py‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ def polygons_to_mask(img_shape, polygons):
7676

7777

7878
def draw_label(label, img, label_names, colormap=None):
79+
backend_org = plt.rcParams['backend']
80+
plt.switch_backend('agg')
81+
7982
plt.subplots_adjust(left=0, right=1, top=1, bottom=0,
8083
wspace=0, hspace=0)
8184
plt.margins(0, 0)
@@ -103,6 +106,8 @@ def draw_label(label, img, label_names, colormap=None):
103106
plt.cla()
104107
plt.close()
105108

109+
plt.switch_backend(backend_org)
110+
106111
out_size = (img.shape[1], img.shape[0])
107112
out = PIL.Image.open(f).resize(out_size, PIL.Image.BILINEAR).convert('RGB')
108113
out = np.asarray(out)

0 commit comments

Comments
 (0)