add delimiter reader
# See the License for the specific language governing permissions and
# limitations under the License.
-import cv2
import numpy as np
import os
import signal
-
+import imghdr
import paddle
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 +174,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]
@@ -187,8 +185,9 @@ def partial_reader(params, full_lines, part_id=0, part_num=1):
def reader():
ops = create_operators(params['transforms'])
+ delimiter = params.get('delimiter', ' ')
for line in full_lines:
- img_path, label = line.split()
+ img_path, label = line.split(delimiter)
img_path = os.path.join(params['data_dir'], img_path)
with open(img_path, 'rb') as f:
img = f.read()
