From 72b36bec81c6ef2b0ff11746cf35b7efc6158033 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=9C=E9=9B=A8=E9=A3=98=E9=9B=B6?= Date: Tue, 29 Dec 2020 15:53:52 +0800 Subject: [PATCH] fix read chinese path bug (#521) --- ppcls/data/reader.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ppcls/data/reader.py b/ppcls/data/reader.py index 7433944c..b8ed405e 100755 --- a/ppcls/data/reader.py +++ b/ppcls/data/reader.py @@ -99,7 +99,7 @@ def create_file_list(params): data_dir = params.get('data_dir', '') params['file_list'] = ".tmp.txt" imgtype_list = {'jpg', 'bmp', 'png', 'jpeg', 'rgb', 'tif', 'tiff'} - with open(params['file_list'], "w") as fout: + with open(params['file_list'], "w", encoding='utf-8') as fout: tmp_file_list = os.listdir(data_dir) for file_name in tmp_file_list: file_path = os.path.join(data_dir, file_name) @@ -134,7 +134,7 @@ def get_file_list(params): if params['mode'] == 'test': create_file_list(params) - with open(params['file_list']) as flist: + with open(params['file_list'], encoding='utf-8') as flist: full_lines = [line.strip() for line in flist] full_lines = shuffle_lines(full_lines, params["shuffle_seed"]) -- GitLab