File tree 1 file changed +5
-3
lines changed
1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -81,7 +81,8 @@ def __init__(self, annotation_file=None):
81
81
if not annotation_file == None :
82
82
print ('loading annotations into memory...' )
83
83
tic = time .time ()
84
- dataset = json .load (open (annotation_file , 'r' ))
84
+ with open (annotation_file , 'r' , encoding = 'utf-8' ) as openFile :
85
+ dataset = json .load (openFile )
85
86
assert type (dataset )== dict , 'annotation file format {} not supported' .format (type (dataset ))
86
87
print ('Done (t={:0.2f}s)' .format (time .time ()- tic ))
87
88
self .dataset = dataset
@@ -314,7 +315,8 @@ def loadRes(self, resFile):
314
315
print ('Loading and preparing results...' )
315
316
tic = time .time ()
316
317
if type (resFile ) == str or (PYTHON_VERSION == 2 and type (resFile ) == unicode ):
317
- anns = json .load (open (resFile ))
318
+ with open (resFile , 'r' , encoding = 'utf-8' ) as openFile :
319
+ anns = json .load (openFile )
318
320
elif type (resFile ) == np .ndarray :
319
321
anns = self .loadNumpyAnnotations (resFile )
320
322
else :
@@ -438,4 +440,4 @@ def annToMask(self, ann):
438
440
"""
439
441
rle = self .annToRLE (ann )
440
442
m = maskUtils .decode (rle )
441
- return m
443
+ return m
You can’t perform that action at this time.
0 commit comments