refine reader to support paddle1.8 API and fix the code style
# See the License for the specific language governing permissions and
# limitations under the License.
-import cv2
import numpy as np
+import imghdr
import os
import signal
-import paddle
+from paddle.fluid.io import multiprocess_reader
from . import imaug
from .imaug import transform
-from .imaug import MixupOperator
from ppcls.utils import logger
trainers_num = int(os.environ.get('PADDLE_TRAINERS_NUM', 1))
@@ -176,7 +175,7 @@ def partial_reader(params, full_lines, part_id=0, part_num=1):
part_id(int): part index of the current partial data
part_num(int): part num of the dataset
"""
- assert part_id < part_num, ("part_num: {} should be larger " \
+ assert part_id < part_num, ("part_num: {} should be larger "
"than part_id: {}".format(part_num, part_id))
full_lines = full_lines[part_id::part_num]
@@ -216,7 +215,7 @@ def mp_reader(params):
for part_id in range(part_num):
readers.append(partial_reader(params, full_lines, part_id, part_num))
- return paddle.reader.multiprocess_reader(readers, use_pipe=False)
+ return multiprocess_reader(readers, use_pipe=False)
def term_mp(sig_num, frame):
