提交 3ecefa48 编写于 作者: W WuHaobo

refine reader to support paddle1.8 API and fix the code style

上级 aab12b17
#copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve.
# copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve.
#
#Licensed under the Apache License, Version 2.0 (the "License");
#you may not use this file except in compliance with the License.
#You may obtain a copy of the License at
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
#Unless required by applicable law or agreed to in writing, software
#distributed under the License is distributed on an "AS IS" BASIS,
#WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#See the License for the specific language governing permissions and
#limitations under the License.
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# 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):
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册