diff --git a/configs/rec/rec_chinese_lite_train.yml b/configs/rec/rec_chinese_lite_train.yml deleted file mode 100755 index 738aaa81a4b6ae72ce9fc9f19c1de9babcc46bcb..0000000000000000000000000000000000000000 --- a/configs/rec/rec_chinese_lite_train.yml +++ /dev/null @@ -1,42 +0,0 @@ -Global: - algorithm: CRNN - use_gpu: true - epoch_num: 300 - log_smooth_window: 20 - print_batch_step: 10 - save_model_dir: output - save_epoch_step: 3 - eval_batch_step: 2000 - train_batch_size_per_card: 256 - test_batch_size_per_card: 256 - image_shape: [3, 32, 100] - max_text_length: 25 - character_type: ch - character_dict_path: ./ppocr/utils/ppocr_keys_v1.txt - loss_type: ctc - reader_yml: ./configs/rec/rec_chinese_reader.yml - pretrain_weights: - infer_img: ./infer_img - -Architecture: - function: ppocr.modeling.architectures.rec_model,RecModel - -Backbone: - function: ppocr.modeling.backbones.rec_mobilenet_v3,MobileNetV3 - scale: 0.5 - model_name: small - -Head: - function: ppocr.modeling.heads.rec_ctc_head,CTCPredict - encoder_type: rnn - SeqRNN: - hidden_size: 48 - -Loss: - function: ppocr.modeling.losses.rec_ctc_loss,CTCLoss - -Optimizer: - function: ppocr.optimizer,AdamDecay - base_lr: 0.001 - beta1: 0.9 - beta2: 0.999 diff --git a/configs/rec/rec_chinese_reader.yml b/configs/rec/rec_chinese_reader.yml deleted file mode 100755 index 9b742753e7e6b7ad4cba7539d67cb692a134d052..0000000000000000000000000000000000000000 --- a/configs/rec/rec_chinese_reader.yml +++ /dev/null @@ -1,13 +0,0 @@ -TrainReader: - reader_function: ppocr.data.rec.dataset_traversal,SimpleReader - num_workers: 8 - img_set_dir: ./train_data - label_file_path: ./train_data/train_label.txt - -EvalReader: - reader_function: ppocr.data.rec.dataset_traversal,SimpleReader - img_set_dir: ./train_data - label_file_path: ./train_data/test_label.txt - -TestReader: - reader_function: ppocr.data.rec.dataset_traversal,SimpleReader diff --git a/configs/rec/rec_ic15_reader.yml b/configs/rec/rec_icdar15_reader.yml similarity index 94% rename from configs/rec/rec_ic15_reader.yml rename to configs/rec/rec_icdar15_reader.yml index 19561dd27e3f1bb0e4de3e2a0cf1c2b3aaf0557f..e34ed42f434d28c1d09b3e4014f0aab5075f2a75 100755 --- a/configs/rec/rec_ic15_reader.yml +++ b/configs/rec/rec_icdar15_reader.yml @@ -11,3 +11,4 @@ EvalReader: TestReader: reader_function: ppocr.data.rec.dataset_traversal,SimpleReader + infer_img: ./infer_img diff --git a/configs/rec/rec_ic15_train.yml b/configs/rec/rec_icdar15_train.yml similarity index 82% rename from configs/rec/rec_ic15_train.yml rename to configs/rec/rec_icdar15_train.yml index 05105f0445853b4ee32b720e1049f3c418f09334..ddaf157f5e0f9e1e222eaa73fc5cc2e097d53470 100755 --- a/configs/rec/rec_ic15_train.yml +++ b/configs/rec/rec_icdar15_train.yml @@ -5,8 +5,8 @@ Global: log_smooth_window: 20 print_batch_step: 10 save_model_dir: output_ic15 - save_epoch_step: 3 - eval_batch_step: 2000 + save_epoch_step: 300 + eval_batch_step: 200 train_batch_size_per_card: 256 test_batch_size_per_card: 256 image_shape: [3, 32, 100] @@ -14,9 +14,8 @@ Global: character_type: ch character_dict_path: ./ppocr/utils/ic15_dict.txt loss_type: ctc - reader_yml: ./configs/rec/rec_ic15_reader.yml - pretrain_weights: ./pretrain_models/best_accuracy - infer_img: ./infer_img + reader_yml: ./configs/rec/rec_icdar15_reader.yml + pretrain_weights: ./pretrain_models/CRNN/best_accuracy Architecture: function: ppocr.modeling.architectures.rec_model,RecModel diff --git a/ppocr/data/rec/dataset_traversal.py b/ppocr/data/rec/dataset_traversal.py index 01d984a77736696a42be968e1131a16645abd8bf..bbd8090accd7d68bfd11270a4f1356524f22a0b6 100755 --- a/ppocr/data/rec/dataset_traversal.py +++ b/ppocr/data/rec/dataset_traversal.py @@ -22,6 +22,7 @@ import string import lmdb from ppocr.utils.utility import initial_logger +from tools.infer.utility import get_image_file_list logger = initial_logger() from .img_tools import process_image, get_img_data @@ -165,15 +166,7 @@ class SimpleReader(object): def sample_iter_reader(): if self.mode == 'test': - image_file_list = [] - if os.path.isfile(self.infer_img): - image_file_list = [self.infer_img] - elif os.path.isdir(self.infer_img): - for single_file in os.listdir(self.infer_img): - if single_file.split('.')[ - -1] not in ['bmp', 'jpg', 'jpeg', 'png', 'JPEG', 'JPG', 'PNG']: - continue - image_file_list.append(os.path.join(self.infer_img, single_file)) + image_file_list = get_image_file_list(self.infer_img) for single_img in image_file_list: img = cv2.imread(single_img) if img.shape[-1]==1 or len(list(img.shape))==2: diff --git a/ppocr/utils/ic15_dict.txt b/ppocr/utils/ic15_dict.txt index c6df88224b06589b57825fdbbafca7774bc238ac..c1f9993dae8be61d968b602ddde5683b8e4ca959 100644 --- a/ppocr/utils/ic15_dict.txt +++ b/ppocr/utils/ic15_dict.txt @@ -1,86 +1,36 @@ -J -O -I -N -T -y -o -u -r -s +a +b +c +d e -l f -1 -5 -4 -9 -7 -2 -8 -0 -F -m -P -A -B -L -C -K -S -R -E -Y -U -p -d g -a -t +h i +j +k +l +m n -h -W -D +o +p +q +r +s +t +u v -H -V -G w -M -! -k -c -. -( -) -X -b -- -Q x -Z -? -@ -3 -/ -% -$ -, -' -: +y z -& -j +0 +1 +2 +3 +4 +5 6 -+ - -[ -] -; -# -q -\ -´ -É -= +7 +8 +9 diff --git a/set_env.sh b/set_env.sh deleted file mode 100644 index 077e5b4687bb4e0aadaaee8270b4b841d9346e60..0000000000000000000000000000000000000000 --- a/set_env.sh +++ /dev/null @@ -1,10 +0,0 @@ -#. /paddle/set_env.sh↩ -export CUDA_VISIBLE_DEVICES="0,1,2,3" -export FLAGS_fraction_of_gpu_memory_to_use=1.0 -python_bin_dir="/opt/_internal/cpython-3.7.0/bin/" -alias python=$python_bin_dir"python3.7" -alias pip=$python_bin_dir"pip3.7" -alias ipython=$python_bin_dir"ipython3" -export LD_LIBRARY_PATH=/opt/_internal/cpython-3.7.0/lib:$LD_LIBRARY_PATH -export PYTHONPATH=$PYTHONPATH:. -ldconfig diff --git a/tools/infer_rec.py b/tools/infer_rec.py index 81f997447686b08d66daad5cae2ed4977dc3e426..8f4919f4d41a3674a9997f1831c888a9f01bf5cf 100755 --- a/tools/infer_rec.py +++ b/tools/infer_rec.py @@ -46,7 +46,7 @@ from ppocr.data.reader_main import reader_main from ppocr.utils.save_load import init_model from ppocr.utils.character import CharacterOps from ppocr.utils.utility import create_module - +from tools.infer.utility import get_image_file_list logger = initial_logger() @@ -79,11 +79,8 @@ def main(): init_model(config, eval_prog, exe) blobs = reader_main(config, 'test')() - infer_img = config['Global']['infer_img'] - if os.path.isfile(infer_img): - infer_list = [infer_img] - elif os.path.isdir(infer_img): - infer_list = os.listdir(config['Global']['infer_img']) + infer_img = config['TestReader']['infer_img'] + infer_list = get_image_file_list(infer_img) max_img_num = len(infer_list) if len(infer_list) == 0: logger.info("Can not find img in infer_img dir.")