未验证 提交 973fdd67 编写于 作者: K Kaipeng Deng 提交者: GitHub

Fix dataset resource warning (#26566)

* fix resource warning. test=develop
上级 c2cb8f00
......@@ -27,7 +27,7 @@ __all__ = ["VOC2012"]
VOC_URL = 'http://host.robots.ox.ac.uk/pascal/VOC/voc2012/\
VOCtrainval_11-May-2012.tar'
VOC_MD5 = '131da710f39b47a43fdfa256cbc11976'
VOC_MD5 = '6cd6e144f989b92b3379bac3b3de84fd'
SET_FILE = 'VOCdevkit/VOC2012/ImageSets/Segmentation/{}.txt'
DATA_FILE = 'VOCdevkit/VOC2012/JPEGImages/{}.jpg'
LABEL_FILE = 'VOCdevkit/VOC2012/SegmentationClass/{}.png'
......@@ -131,3 +131,7 @@ class VOC2012(Dataset):
def __len__(self):
return len(self.data)
def __del__(self):
if self.data_tar:
self.data_tar.close()
......@@ -139,8 +139,11 @@ class WMT16(Dataset):
def _load_dict(self, lang, dict_size, reverse=False):
dict_path = os.path.join(paddle.dataset.common.DATA_HOME,
"wmt16/%s_%d.dict" % (lang, dict_size))
if not os.path.exists(dict_path) or (
len(open(dict_path, "rb").readlines()) != dict_size):
dict_found = False
if os.path.exists(dict_path):
with open(dict_path, "rb") as d:
dict_found = len(d.readlines()) == dict_size
if not dict_found:
self._build_dict(dict_path, dict_size, lang)
word_dict = {}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册