From 638f95ad108b9d08cbe8397af54f70fc037930ac Mon Sep 17 00:00:00 2001 From: walloollaw <37680514+walloollaw@users.noreply.github.com> Date: Wed, 31 Jul 2019 20:30:04 +0800 Subject: [PATCH] fix bug about data_feed.py (#2989) --- PaddleCV/PaddleDetection/ppdet/core/workspace.py | 3 ++- PaddleCV/PaddleDetection/ppdet/data/data_feed.py | 13 +++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/PaddleCV/PaddleDetection/ppdet/core/workspace.py b/PaddleCV/PaddleDetection/ppdet/core/workspace.py index c922b3b3..64c0be1f 100644 --- a/PaddleCV/PaddleDetection/ppdet/core/workspace.py +++ b/PaddleCV/PaddleDetection/ppdet/core/workspace.py @@ -59,7 +59,8 @@ def load_config(file_path): """ _, ext = os.path.splitext(file_path) assert ext in ['.yml', '.yaml'], "only support yaml files for now" - merge_config(yaml.load(open(file_path), Loader=yaml.Loader)) + with open(file_path) as f: + merge_config(yaml.load(f, Loader=yaml.Loader)) return global_config diff --git a/PaddleCV/PaddleDetection/ppdet/data/data_feed.py b/PaddleCV/PaddleDetection/ppdet/data/data_feed.py index dd85e83f..238b1006 100644 --- a/PaddleCV/PaddleDetection/ppdet/data/data_feed.py +++ b/PaddleCV/PaddleDetection/ppdet/data/data_feed.py @@ -58,12 +58,6 @@ def _prepare_data_config(feed, args_path): mixup_epoch = -1 if getattr(feed, 'mixup_epoch', None) is not None: mixup_epoch = feed.mixup_epoch - bufsize = 10 - use_process = False - if getattr(feed, 'bufsize', None) is not None: - bufsize = feed.bufsize - if getattr(feed, 'use_process', None) is not None: - use_process = feed.use_process data_config = { 'ANNO_FILE': feed.dataset.annotation, @@ -96,6 +90,13 @@ def create_reader(feed, max_iter=0, args_path=None, my_source=None): # named `DATASET_DIR` (e.g., coco, pascal), if not present either, download data_config = _prepare_data_config(feed, args_path) + bufsize = 10 + use_process = False + if getattr(feed, 'bufsize', None) is not None: + bufsize = feed.bufsize + if getattr(feed, 'use_process', None) is not None: + use_process = feed.use_process + transform_config = { 'WORKER_CONF': { 'bufsize': bufsize, -- GitLab