From 990b7d7bc9e7f4963d4555ab2dc1dce40ae28bb3 Mon Sep 17 00:00:00 2001 From: wanghaoshuang Date: Mon, 5 Jun 2017 16:40:12 +0800 Subject: [PATCH] rename xmap to xmap_readers and remove 'from cv2 import resize' in image.py --- python/paddle/v2/dataset/flowers.py | 3 ++- python/paddle/v2/image.py | 4 +--- python/paddle/v2/reader/decorator.py | 4 ++-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/python/paddle/v2/dataset/flowers.py b/python/paddle/v2/dataset/flowers.py index d9a39b11d..07c13cf71 100644 --- a/python/paddle/v2/dataset/flowers.py +++ b/python/paddle/v2/dataset/flowers.py @@ -105,7 +105,8 @@ def reader_creator(data_file, for sample, label in itertools.izip(data, batch['label']): yield sample, int(label) - return paddle.reader.xmap(mapper, reader, cpu_count(), buffered_size) + return paddle.reader.xmap_readers(mapper, reader, + cpu_count(), buffered_size) def train(mapper=default_mapper, buffered_size=1024): diff --git a/python/paddle/v2/image.py b/python/paddle/v2/image.py index 56031e873..0d648e9ae 100644 --- a/python/paddle/v2/image.py +++ b/python/paddle/v2/image.py @@ -3,8 +3,6 @@ try: import cv2 except ImportError: cv2 = None - -from cv2 import resize import os import tarfile import cPickle @@ -164,7 +162,7 @@ def resize_short(im, size): h_new = size * h / w else: w_new = size * w / h - im = resize(im, (h_new, w_new), interpolation=cv2.INTER_CUBIC) + im = cv2.resize(im, (h_new, w_new), interpolation=cv2.INTER_CUBIC) return im diff --git a/python/paddle/v2/reader/decorator.py b/python/paddle/v2/reader/decorator.py index 1b5df21b3..c76faa596 100644 --- a/python/paddle/v2/reader/decorator.py +++ b/python/paddle/v2/reader/decorator.py @@ -14,7 +14,7 @@ __all__ = [ 'map_readers', 'buffered', 'compose', 'chain', 'shuffle', - 'ComposeNotAligned', 'firstn', 'xmap' + 'ComposeNotAligned', 'firstn', 'xmap_readers' ] import itertools @@ -230,7 +230,7 @@ class XmapEndSignal(): pass -def xmap(mapper, reader, process_num, buffer_size): +def xmap_readers(mapper, reader, process_num, buffer_size): """ Use multiprocess to map samples from reader by a mapper defined by user. And this function contains a buffered decorator. -- GitLab