├── .gitignore
├── configs
├── cls
│ ├── ch_PP-OCRv3
│ │ └── ch_PP-OCRv3_rotnet.yml
│ └── cls_mv3.yml
├── det
│ ├── ch_PP-OCRv2
│ │ ├── ch_PP-OCRv2_det_cml.yml
│ │ ├── ch_PP-OCRv2_det_distill.yml
│ │ ├── ch_PP-OCRv2_det_dml.yml
│ │ └── ch_PP-OCRv2_det_student.yml
│ ├── ch_PP-OCRv3
│ │ ├── ch_PP-OCRv3_det_cml.yml
│ │ ├── ch_PP-OCRv3_det_dml.yml
│ │ └── ch_PP-OCRv3_det_student.yml
│ ├── ch_PP-OCRv4
│ │ ├── ch_PP-OCRv4_det_cml.yml
│ │ ├── ch_PP-OCRv4_det_student.yml
│ │ └── ch_PP-OCRv4_det_teacher.yml
│ ├── ch_ppocr_v2.0
│ │ ├── ch_det_mv3_db_v2.0.yml
│ │ └── ch_det_res18_db_v2.0.yml
│ ├── det_mv3_db.yml
│ ├── det_mv3_east.yml
│ ├── det_mv3_pse.yml
│ ├── det_r18_vd_ct.yml
│ ├── det_r50_db++_icdar15.yml
│ ├── det_r50_db++_td_tr.yml
│ ├── det_r50_drrg_ctw.yml
│ ├── det_r50_vd_db.yml
│ ├── det_r50_vd_dcn_fce_ctw.yml
│ ├── det_r50_vd_east.yml
│ ├── det_r50_vd_pse.yml
│ ├── det_r50_vd_sast_icdar15.yml
│ ├── det_r50_vd_sast_totaltext.yml
│ └── det_res18_db_v2.0.yml
├── e2e
│ └── e2e_r50_vd_pg.yml
├── kie
│ ├── layoutlm_series
│ │ ├── re_layoutlmv2_xfund_zh.yml
│ │ ├── re_layoutxlm_xfund_zh.yml
│ │ ├── ser_layoutlm_xfund_zh.yml
│ │ ├── ser_layoutlmv2_xfund_zh.yml
│ │ └── ser_layoutxlm_xfund_zh.yml
│ ├── sdmgr
│ │ └── kie_unet_sdmgr.yml
│ └── vi_layoutxlm
│ │ ├── re_vi_layoutxlm_xfund_zh.yml
│ │ ├── re_vi_layoutxlm_xfund_zh_udml.yml
│ │ ├── ser_vi_layoutxlm_xfund_zh.yml
│ │ └── ser_vi_layoutxlm_xfund_zh_udml.yml
├── rec
│ ├── PP-OCRv3
│ │ ├── ch_PP-OCRv3_rec.yml
│ │ └── ch_PP-OCRv3_rec_distillation.yml
│ ├── PP-OCRv4
│ │ ├── ch_PP-OCRv4_rec.yml
│ │ ├── ch_PP-OCRv4_rec_distill.yml
│ │ └── ch_PP-OCRv4_rec_hgnet.yml
│ ├── ch_PP-OCRv2
│ │ ├── ch_PP-OCRv2_rec.yml
│ │ ├── ch_PP-OCRv2_rec_distillation.yml
│ │ └── ch_PP-OCRv2_rec_enhanced_ctc_loss.yml
│ ├── ch_ppocr_v2.0
│ │ ├── rec_chinese_common_train_v2.0.yml
│ │ └── rec_chinese_lite_train_v2.0.yml
│ ├── multi_language
│ │ ├── generate_multi_language_configs.py
│ │ ├── rec_arabic_lite_train.yml
│ │ ├── rec_cyrillic_lite_train.yml
│ │ ├── rec_devanagari_lite_train.yml
│ │ ├── rec_en_number_lite_train.yml
│ │ ├── rec_french_lite_train.yml
│ │ ├── rec_german_lite_train.yml
│ │ ├── rec_japan_lite_train.yml
│ │ ├── rec_korean_lite_train.yml
│ │ ├── rec_latin_lite_train.yml
│ │ └── rec_multi_language_lite_train.yml
│ ├── rec_d28_can.yml
│ ├── rec_efficientb3_fpn_pren.yml
│ ├── rec_icdar15_train.yml
│ ├── rec_mtb_nrtr.yml
│ ├── rec_mv3_none_bilstm_ctc.yml
│ ├── rec_mv3_none_none_ctc.yml
│ ├── rec_mv3_tps_bilstm_att.yml
│ ├── rec_mv3_tps_bilstm_ctc.yml
│ ├── rec_r31_robustscanner.yml
│ ├── rec_r31_sar.yml
│ ├── rec_r32_gaspin_bilstm_att.yml
│ ├── rec_r34_vd_none_bilstm_ctc.yml
│ ├── rec_r34_vd_none_none_ctc.yml
│ ├── rec_r34_vd_tps_bilstm_att.yml
│ ├── rec_r34_vd_tps_bilstm_ctc.yml
│ ├── rec_r45_abinet.yml
│ ├── rec_r45_visionlan.yml
│ ├── rec_r50_fpn_srn.yml
│ ├── rec_resnet_rfl_att.yml
│ ├── rec_resnet_rfl_visual.yml
│ ├── rec_resnet_stn_bilstm_att.yml
│ ├── rec_satrn.yml
│ ├── rec_svtrnet.yml
│ ├── rec_svtrnet_ch.yml
│ └── rec_vitstr_none_ce.yml
├── sr
│ ├── sr_telescope.yml
│ └── sr_tsrn_transformer_strock.yml
└── table
│ ├── SLANet.yml
│ ├── SLANet_ch.yml
│ ├── table_master.yml
│ └── table_mv3.yml
├── convert_params_compute_diff.py
├── doc
├── fonts
│ └── simfang.ttf
├── imgs
│ ├── 00006737.jpg
│ ├── 00009282.jpg
│ ├── 00015504.jpg
│ ├── 00018069.jpg
│ ├── 00056221.jpg
│ ├── 00057937.jpg
│ ├── 00059985.jpg
│ ├── 00077949.jpg
│ ├── 00111002.jpg
│ ├── 00207393.jpg
│ ├── 1.jpg
│ ├── 11.jpg
│ ├── 12.jpg
│ ├── french_0.jpg
│ ├── ger_1.jpg
│ ├── ger_2.jpg
│ ├── japan_1.jpg
│ ├── japan_2.jpg
│ ├── korean_1.jpg
│ └── model_prod_flow_ch.png
└── imgs_words
│ ├── arabic
│ ├── ar_1.jpg
│ └── ar_2.jpg
│ ├── belarusian
│ ├── be_1.jpg
│ └── be_2.jpg
│ ├── bulgarian
│ ├── bg_1.jpg
│ └── bg_2.jpg
│ ├── ch
│ ├── word_1.jpg
│ ├── word_2.jpg
│ ├── word_3.jpg
│ ├── word_4.jpg
│ └── word_5.jpg
│ ├── chinese_traditional
│ ├── chinese_cht_1.png
│ └── chinese_cht_2.png
│ ├── en
│ ├── word_1.png
│ ├── word_2.png
│ ├── word_3.png
│ ├── word_4.png
│ └── word_5.png
│ ├── french
│ ├── 1.jpg
│ └── 2.jpg
│ ├── german
│ └── 1.jpg
│ ├── hindi
│ ├── hi_1.jpg
│ └── hi_2.jpg
│ ├── italian
│ ├── it_1.jpg
│ └── it_2.jpg
│ ├── japan
│ └── 1.jpg
│ ├── kannada
│ ├── ka_1.jpg
│ └── ka_2.jpg
│ ├── korean
│ ├── 1.jpg
│ └── 2.jpg
│ ├── marathi
│ ├── mr_1.jpg
│ └── mr_2.jpg
│ ├── nepali
│ ├── ne_1.jpg
│ └── ne_2.jpg
│ ├── occitan
│ ├── oc_1.jpg
│ └── oc_2.jpg
│ ├── persian
│ ├── fa_1.jpg
│ └── fa_2.jpg
│ ├── portuguese
│ ├── pu_1.jpg
│ └── pu_2.jpg
│ ├── russia
│ ├── ru_1.jpg
│ └── ru_2.jpg
│ ├── serbian_cyrillic
│ ├── rsc_1.jpg
│ └── rsc_2.jpg
│ ├── serbian_latin
│ ├── rs_1.jpg
│ └── rs_2.jpg
│ ├── spanish
│ ├── xi_1.jpg
│ └── xi_2.jpg
│ ├── tamil
│ ├── ta_1.jpg
│ └── ta_2.jpg
│ ├── telugu
│ ├── te_1.jpg
│ └── te_2.jpg
│ ├── ukranian
│ ├── uk_1.jpg
│ └── uk_2.jpg
│ ├── urdu
│ ├── ur_1.jpg
│ └── ur_2.jpg
│ └── uyghur
│ ├── ug_1.jpg
│ └── ug_2.jpg
├── padiff
├── __init__.py
├── abstracts
│ ├── __init__.py
│ ├── marker.py
│ ├── proxy_model.py
│ ├── proxy_parameter.py
│ └── proxy_utils.py
├── checker
│ ├── __init__.py
│ ├── actions.py
│ ├── check_params.py
│ ├── check_report.py
│ └── checker_utils.py
├── datas
│ ├── __init__.py
│ ├── api_mapping.json
│ ├── assign_weight.yaml
│ └── file_loader.py
├── dump_tools.py
├── interfaces
│ ├── __init__.py
│ ├── diff_utils.py
│ └── interfaces.py
├── report
│ ├── __init__.py
│ ├── hooks.py
│ ├── module_struct.py
│ └── report.py
├── utils.py
└── weight_init
│ ├── __init__.py
│ ├── special_init
│ ├── __init__.py
│ ├── init_BatchNorm2D.py
│ ├── init_Embeddings.py
│ ├── init_LSTM.py
│ ├── init_MultiHeadAttention.py
│ └── special_init_pool.py
│ └── weights.py
├── ppocr
├── __init__.py
├── data
│ ├── __init__.py
│ ├── collate_fn.py
│ ├── imaug
│ │ ├── ColorJitter.py
│ │ ├── __init__.py
│ │ ├── abinet_aug.py
│ │ ├── copy_paste.py
│ │ ├── ct_process.py
│ │ ├── drrg_targets.py
│ │ ├── east_process.py
│ │ ├── fce_aug.py
│ │ ├── fce_targets.py
│ │ ├── iaa_augment.py
│ │ ├── label_ops.py
│ │ ├── make_border_map.py
│ │ ├── make_pse_gt.py
│ │ ├── make_shrink_map.py
│ │ ├── operators.py
│ │ ├── pg_process.py
│ │ ├── randaugment.py
│ │ ├── random_crop_data.py
│ │ ├── rec_img_aug.py
│ │ ├── sast_process.py
│ │ ├── ssl_img_aug.py
│ │ ├── table_ops.py
│ │ ├── text_image_aug
│ │ │ ├── __init__.py
│ │ │ ├── augment.py
│ │ │ └── warp_mls.py
│ │ └── vqa
│ │ │ ├── __init__.py
│ │ │ ├── augment.py
│ │ │ └── token
│ │ │ ├── __init__.py
│ │ │ ├── vqa_re_convert.py
│ │ │ ├── vqa_token_chunk.py
│ │ │ ├── vqa_token_pad.py
│ │ │ └── vqa_token_relation.py
│ ├── lmdb_dataset.py
│ ├── multi_scale_sampler.py
│ ├── pgnet_dataset.py
│ ├── pubtab_dataset.py
│ └── simple_dataset.py
├── ext_op
│ ├── __init__.py
│ └── roi_align_rotated
│ │ ├── roi_align_rotated.cc
│ │ ├── roi_align_rotated.cu
│ │ └── roi_align_rotated.py
├── losses
│ ├── __init__.py
│ ├── ace_loss.py
│ ├── basic_loss.py
│ ├── center_loss.py
│ ├── cls_loss.py
│ ├── combined_loss.py
│ ├── det_basic_loss.py
│ ├── det_ct_loss.py
│ ├── det_db_loss.py
│ ├── det_drrg_loss.py
│ ├── det_east_loss.py
│ ├── det_fce_loss.py
│ ├── det_pse_loss.py
│ ├── det_sast_loss.py
│ ├── distillation_loss.py
│ ├── e2e_pg_loss.py
│ ├── kie_sdmgr_loss.py
│ ├── rec_aster_loss.py
│ ├── rec_att_loss.py
│ ├── rec_can_loss.py
│ ├── rec_ce_loss.py
│ ├── rec_ctc_loss.py
│ ├── rec_enhanced_ctc_loss.py
│ ├── rec_multi_loss.py
│ ├── rec_nrtr_loss.py
│ ├── rec_pren_loss.py
│ ├── rec_rfl_loss.py
│ ├── rec_sar_loss.py
│ ├── rec_satrn_loss.py
│ ├── rec_spin_att_loss.py
│ ├── rec_srn_loss.py
│ ├── rec_vl_loss.py
│ ├── stroke_focus_loss.py
│ ├── table_att_loss.py
│ ├── table_master_loss.py
│ ├── text_focus_loss.py
│ └── vqa_token_layoutlm_loss.py
├── metrics
│ ├── __init__.py
│ ├── cls_metric.py
│ ├── ct_metric.py
│ ├── det_metric.py
│ ├── distillation_metric.py
│ ├── e2e_metric.py
│ ├── eval_det_iou.py
│ ├── kie_metric.py
│ ├── rec_metric.py
│ ├── sr_metric.py
│ ├── table_metric.py
│ ├── vqa_token_re_metric.py
│ └── vqa_token_ser_metric.py
├── modeling
│ ├── architectures
│ │ ├── __init__.py
│ │ ├── base_model.py
│ │ └── distillation_model.py
│ ├── backbones
│ │ ├── __init__.py
│ │ ├── det_mobilenet_v3.py
│ │ ├── det_pp_lcnet.py
│ │ ├── det_resnet.py
│ │ ├── det_resnet_vd.py
│ │ ├── det_resnet_vd_sast.py
│ │ ├── e2e_resnet_vd_pg.py
│ │ ├── kie_unet_sdmgr.py
│ │ ├── rec_densenet.py
│ │ ├── rec_efficientb3_pren.py
│ │ ├── rec_hgnet.py
│ │ ├── rec_lcnetv3.py
│ │ ├── rec_micronet.py
│ │ ├── rec_mobilenet_v3.py
│ │ ├── rec_mv1_enhance.py
│ │ ├── rec_nrtr_mtb.py
│ │ ├── rec_resnet_31.py
│ │ ├── rec_resnet_32.py
│ │ ├── rec_resnet_45.py
│ │ ├── rec_resnet_aster.py
│ │ ├── rec_resnet_fpn.py
│ │ ├── rec_resnet_rfl.py
│ │ ├── rec_resnet_vd.py
│ │ ├── rec_shallow_cnn.py
│ │ ├── rec_svtrnet.py
│ │ ├── rec_vitstr.py
│ │ ├── table_master_resnet.py
│ │ └── vqa_layoutlm.py
│ ├── heads
│ │ ├── __init__.py
│ │ ├── cls_head.py
│ │ ├── det_ct_head.py
│ │ ├── det_db_head.py
│ │ ├── det_drrg_head.py
│ │ ├── det_east_head.py
│ │ ├── det_fce_head.py
│ │ ├── det_pse_head.py
│ │ ├── det_sast_head.py
│ │ ├── e2e_pg_head.py
│ │ ├── gcn.py
│ │ ├── kie_sdmgr_head.py
│ │ ├── local_graph.py
│ │ ├── proposal_local_graph.py
│ │ ├── rec_abinet_head.py
│ │ ├── rec_aster_head.py
│ │ ├── rec_att_head.py
│ │ ├── rec_can_head.py
│ │ ├── rec_ctc_head.py
│ │ ├── rec_multi_head.py
│ │ ├── rec_nrtr_head.py
│ │ ├── rec_pren_head.py
│ │ ├── rec_rfl_head.py
│ │ ├── rec_robustscanner_head.py
│ │ ├── rec_sar_head.py
│ │ ├── rec_satrn_head.py
│ │ ├── rec_spin_att_head.py
│ │ ├── rec_srn_head.py
│ │ ├── rec_visionlan_head.py
│ │ ├── self_attention.py
│ │ ├── sr_rensnet_transformer.py
│ │ ├── table_att_head.py
│ │ └── table_master_head.py
│ ├── necks
│ │ ├── __init__.py
│ │ ├── csp_pan.py
│ │ ├── ct_fpn.py
│ │ ├── db_fpn.py
│ │ ├── east_fpn.py
│ │ ├── fce_fpn.py
│ │ ├── fpn.py
│ │ ├── fpn_unet.py
│ │ ├── intracl.py
│ │ ├── pg_fpn.py
│ │ ├── pren_fpn.py
│ │ ├── rf_adaptor.py
│ │ ├── rnn.py
│ │ ├── sast_fpn.py
│ │ └── table_fpn.py
│ └── transforms
│ │ ├── __init__.py
│ │ ├── gaspin_transformer.py
│ │ ├── stn.py
│ │ ├── tbsrn.py
│ │ ├── tps.py
│ │ ├── tps_spatial_transformer.py
│ │ └── tsrn.py
├── optimizer
│ ├── __init__.py
│ ├── learning_rate.py
│ ├── lr_scheduler.py
│ ├── optimizer.py
│ └── regularizer.py
├── postprocess
│ ├── __init__.py
│ ├── cls_postprocess.py
│ ├── ct_postprocess.py
│ ├── db_postprocess.py
│ ├── drrg_postprocess.py
│ ├── east_postprocess.py
│ ├── fce_postprocess.py
│ ├── locality_aware_nms.py
│ ├── pg_postprocess.py
│ ├── picodet_postprocess.py
│ ├── pse_postprocess
│ │ ├── __init__.py
│ │ ├── pse
│ │ │ ├── README.md
│ │ │ ├── __init__.py
│ │ │ ├── pse.pyx
│ │ │ └── setup.py
│ │ └── pse_postprocess.py
│ ├── rec_postprocess.py
│ ├── sast_postprocess.py
│ ├── table_postprocess.py
│ ├── vqa_token_re_layoutlm_postprocess.py
│ └── vqa_token_ser_layoutlm_postprocess.py
└── utils
│ ├── EN_symbol_dict.txt
│ ├── __init__.py
│ ├── dict
│ ├── ar_dict.txt
│ ├── arabic_dict.txt
│ ├── be_dict.txt
│ ├── bg_dict.txt
│ ├── chinese_cht_dict.txt
│ ├── confuse.pkl
│ ├── cyrillic_dict.txt
│ ├── devanagari_dict.txt
│ ├── en_dict.txt
│ ├── fa_dict.txt
│ ├── french_dict.txt
│ ├── german_dict.txt
│ ├── hi_dict.txt
│ ├── it_dict.txt
│ ├── japan_dict.txt
│ ├── ka_dict.txt
│ ├── kie_dict
│ │ └── xfund_class_list.txt
│ ├── korean_dict.txt
│ ├── latex_symbol_dict.txt
│ ├── latin_dict.txt
│ ├── layout_dict
│ │ ├── layout_cdla_dict.txt
│ │ ├── layout_publaynet_dict.txt
│ │ └── layout_table_dict.txt
│ ├── mr_dict.txt
│ ├── ne_dict.txt
│ ├── oc_dict.txt
│ ├── pu_dict.txt
│ ├── rs_dict.txt
│ ├── rsc_dict.txt
│ ├── ru_dict.txt
│ ├── spin_dict.txt
│ ├── ta_dict.txt
│ ├── table_dict.txt
│ ├── table_master_structure_dict.txt
│ ├── table_structure_dict.txt
│ ├── table_structure_dict_ch.txt
│ ├── te_dict.txt
│ ├── ug_dict.txt
│ ├── uk_dict.txt
│ ├── ur_dict.txt
│ └── xi_dict.txt
│ ├── dict90.txt
│ ├── e2e_metric
│ ├── Deteval.py
│ └── polygon_fast.py
│ ├── e2e_utils
│ ├── extract_batchsize.py
│ ├── extract_textpoint_fast.py
│ ├── extract_textpoint_slow.py
│ ├── pgnet_pp_utils.py
│ └── visual.py
│ ├── en_dict.txt
│ ├── gen_label.py
│ ├── ic15_dict.txt
│ ├── iou.py
│ ├── loggers
│ ├── __init__.py
│ ├── base_logger.py
│ ├── loggers.py
│ ├── vdl_logger.py
│ └── wandb_logger.py
│ ├── logging.py
│ ├── network.py
│ ├── poly_nms.py
│ ├── ppocr_keys_v1.txt
│ ├── profiler.py
│ ├── save_load.py
│ ├── stats.py
│ ├── utility.py
│ └── visual.py
├── readme.md
├── requirements.txt
├── tools
├── create_lmdb_dataset.py
├── eval.py
├── export.py
├── infer
│ ├── onnx_engine.py
│ ├── predict_cls.py
│ ├── predict_det.py
│ ├── predict_rec.py
│ ├── predict_system.py
│ └── utility.py
├── infer_cls.py
├── infer_det.py
├── infer_rec.py
├── train.py
└── utility.py
└── torchocr
├── __init__.py
├── data
├── __init__.py
├── cache.py
├── collate_fn.py
├── imaug
│ ├── ColorJitter.py
│ ├── __init__.py
│ ├── abinet_aug.py
│ ├── copy_paste.py
│ ├── ct_process.py
│ ├── drrg_targets.py
│ ├── east_process.py
│ ├── fce_aug.py
│ ├── fce_targets.py
│ ├── iaa_augment.py
│ ├── label_ops.py
│ ├── make_border_map.py
│ ├── make_pse_gt.py
│ ├── make_shrink_map.py
│ ├── operators.py
│ ├── pg_process.py
│ ├── randaugment.py
│ ├── random_crop_data.py
│ ├── rec_img_aug.py
│ ├── sast_process.py
│ ├── ssl_img_aug.py
│ ├── table_ops.py
│ └── text_image_aug
│ │ ├── __init__.py
│ │ ├── augment.py
│ │ └── warp_mls.py
├── lmdb_dataset.py
├── multi_scale_sampler.py
├── pgnet_dataset.py
├── pubtab_dataset.py
└── simple_dataset.py
├── engine
├── __init__.py
├── config.py
└── trainer.py
├── losses
├── __init__.py
├── ace_loss.py
├── basic_loss.py
├── center_loss.py
├── cls_loss.py
├── combined_loss.py
├── det_basic_loss.py
├── det_ct_loss.py
├── det_db_loss.py
├── det_drrg_loss.py
├── det_east_loss.py
├── det_fce_loss.py
├── det_pse_loss.py
├── det_sast_loss.py
├── distillation_loss.py
├── e2e_pg_loss.py
├── kd_loss.py
├── kie_sdmgr_loss.py
├── rec_aster_loss.py
├── rec_att_loss.py
├── rec_can_loss.py
├── rec_ce_loss.py
├── rec_ctc_loss.py
├── rec_enhanced_ctc_loss.py
├── rec_multi_loss.py
├── rec_nrtr_loss.py
├── rec_pren_loss.py
├── rec_rfl_loss.py
├── rec_sar_loss.py
├── rec_satrn_loss.py
├── rec_spin_att_loss.py
├── rec_srn_loss.py
├── rec_vl_loss.py
├── stroke_focus_loss.py
├── table_att_loss.py
├── table_master_loss.py
└── text_focus_loss.py
├── metrics
├── __init__.py
├── cls_metric.py
├── det_metric.py
├── distillation_metric.py
├── e2e_metric.py
├── eval_det_iou.py
└── rec_metric.py
├── modeling
├── architectures
│ ├── __init__.py
│ ├── base_model.py
│ └── distillation_model.py
├── backbones
│ ├── __init__.py
│ ├── det_mobilenet_v3.py
│ ├── det_resnet_vd.py
│ ├── rec_hgnet.py
│ ├── rec_lcnetv3.py
│ ├── rec_mobilenet_v3.py
│ ├── rec_mv1_enhance.py
│ ├── rec_nrtr_mtb.py
│ ├── rec_resnet_31.py
│ ├── rec_resnet_vd.py
│ └── rec_svtrnet.py
├── common.py
├── heads
│ ├── __init__.py
│ ├── cls_head.py
│ ├── det_db_head.py
│ ├── multiheadAttention.py
│ ├── rec_att_head.py
│ ├── rec_ctc_head.py
│ ├── rec_multi_head.py
│ ├── rec_nrtr_head.py
│ └── rec_sar_head.py
├── necks
│ ├── __init__.py
│ ├── db_fpn.py
│ ├── intracl.py
│ └── rnn.py
└── transforms
│ ├── __init__.py
│ └── tps.py
├── optimizer
├── __init__.py
└── lr.py
├── postprocess
├── __init__.py
├── cls_postprocess.py
├── ct_postprocess.py
├── db_postprocess.py
├── drrg_postprocess.py
├── east_postprocess.py
├── fce_postprocess.py
├── locality_aware_nms.py
├── pg_postprocess.py
├── picodet_postprocess.py
├── pse_postprocess
│ ├── __init__.py
│ ├── pse
│ │ ├── README.md
│ │ ├── __init__.py
│ │ ├── pse.pyx
│ │ └── setup.py
│ └── pse_postprocess.py
├── rec_postprocess.py
├── sast_postprocess.py
└── table_postprocess.py
└── utils
├── EN_symbol_dict.txt
├── __init__.py
├── ckpt.py
├── dict
├── ar_dict.txt
├── arabic_dict.txt
├── be_dict.txt
├── bg_dict.txt
├── chinese_cht_dict.txt
├── confuse.pkl
├── cyrillic_dict.txt
├── devanagari_dict.txt
├── en_dict.txt
├── fa_dict.txt
├── french_dict.txt
├── german_dict.txt
├── hi_dict.txt
├── it_dict.txt
├── japan_dict.txt
├── ka_dict.txt
├── kie_dict
│ └── xfund_class_list.txt
├── korean_dict.txt
├── latex_symbol_dict.txt
├── latin_dict.txt
├── layout_dict
│ ├── layout_cdla_dict.txt
│ ├── layout_publaynet_dict.txt
│ └── layout_table_dict.txt
├── mr_dict.txt
├── ne_dict.txt
├── oc_dict.txt
├── pu_dict.txt
├── rs_dict.txt
├── rsc_dict.txt
├── ru_dict.txt
├── spin_dict.txt
├── ta_dict.txt
├── table_dict.txt
├── table_master_structure_dict.txt
├── table_structure_dict.txt
├── table_structure_dict_ch.txt
├── te_dict.txt
├── ug_dict.txt
├── uk_dict.txt
├── ur_dict.txt
└── xi_dict.txt
├── dict90.txt
├── e2e_metric
├── Deteval.py
└── polygon_fast.py
├── e2e_utils
├── extract_batchsize.py
├── extract_textpoint_fast.py
├── extract_textpoint_slow.py
├── pgnet_pp_utils.py
└── visual.py
├── en_dict.txt
├── gen_label.py
├── ic15_dict.txt
├── logging.py
├── poly_nms.py
├── ppocr_keys_v1.txt
├── stats.py
├── utility.py
└── visual.py
/.gitignore:
--------------------------------------------------------------------------------
1 | # Byte-compiled / optimized / DLL files
2 | __pycache__/
3 | .ipynb_checkpoints/
4 | *.py[cod]
5 | *$py.class
6 |
7 | # C extensions
8 | *.so
9 |
10 | inference/
11 | inference_results/
12 | output/
13 | train_data/
14 | log/
15 | *.DS_Store
16 | *.vs
17 | *.user
18 | *~
19 | *.vscode
20 | *.idea
21 |
22 | *.log
23 | .clang-format
24 | .clang_format.hook
25 |
26 | build/
27 | dist/
28 | ppocr/
29 | .idea/
30 | pretrain_models
--------------------------------------------------------------------------------
/configs/sr/sr_telescope.yml:
--------------------------------------------------------------------------------
1 | Global:
2 | use_gpu: true
3 | epoch_num: 100
4 | log_smooth_window: 20
5 | print_batch_step: 10
6 | output_dir: ./output/sr/sr_telescope/
7 | save_epoch_step: 3
8 | # evaluation is run every 2000 iterations
9 | eval_batch_step: [0, 1000]
10 | cal_metric_during_train: False
11 | pretrained_model:
12 | checkpoints:
13 | save_inference_dir: ./output/sr/sr_telescope/infer
14 | use_visualdl: False
15 | infer_img: doc/imgs_words_en/word_52.png
16 | # for data or label process
17 | character_dict_path:
18 | max_text_length: 100
19 | infer_mode: False
20 | use_space_char: False
21 | save_res_path: ./output/sr/predicts_telescope.txt
22 |
23 | Optimizer:
24 | name: Adam
25 | beta1: 0.5
26 | beta2: 0.999
27 | clip_norm: 0.25
28 | lr:
29 | learning_rate: 0.0001
30 |
31 | Architecture:
32 | model_type: sr
33 | algorithm: Telescope
34 | Transform:
35 | name: TBSRN
36 | STN: True
37 | infer_mode: False
38 |
39 | Loss:
40 | name: TelescopeLoss
41 | confuse_dict_path: ./ppocr/utils/dict/confuse.pkl
42 |
43 |
44 | PostProcess:
45 | name: None
46 |
47 | Metric:
48 | name: SRMetric
49 | main_indicator: all
50 |
51 | Train:
52 | dataset:
53 | name: LMDBDataSetSR
54 | data_dir: ./train_data/TextZoom/train
55 | transforms:
56 | - SRResize:
57 | imgH: 32
58 | imgW: 128
59 | down_sample_scale: 2
60 | - KeepKeys:
61 | keep_keys: ['img_lr', 'img_hr', 'label'] # dataloader will return list in this order
62 | loader:
63 | shuffle: False
64 | batch_size_per_card: 16
65 | drop_last: True
66 | num_workers: 4
67 |
68 | Eval:
69 | dataset:
70 | name: LMDBDataSetSR
71 | data_dir: ./train_data/TextZoom/test
72 | transforms:
73 | - SRResize:
74 | imgH: 32
75 | imgW: 128
76 | down_sample_scale: 2
77 | - KeepKeys:
78 | keep_keys: ['img_lr', 'img_hr', 'label'] # dataloader will return list in this order
79 | loader:
80 | shuffle: False
81 | drop_last: False
82 | batch_size_per_card: 16
83 | num_workers: 4
84 |
85 |
--------------------------------------------------------------------------------
/doc/fonts/simfang.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WenmuZhou/PytorchOCR/f899e9ddf953cbbcfb3f269318d0daa5ebcd2b53/doc/fonts/simfang.ttf
--------------------------------------------------------------------------------
/doc/imgs/00006737.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WenmuZhou/PytorchOCR/f899e9ddf953cbbcfb3f269318d0daa5ebcd2b53/doc/imgs/00006737.jpg
--------------------------------------------------------------------------------
/doc/imgs/00009282.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WenmuZhou/PytorchOCR/f899e9ddf953cbbcfb3f269318d0daa5ebcd2b53/doc/imgs/00009282.jpg
--------------------------------------------------------------------------------
/doc/imgs/00015504.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WenmuZhou/PytorchOCR/f899e9ddf953cbbcfb3f269318d0daa5ebcd2b53/doc/imgs/00015504.jpg
--------------------------------------------------------------------------------
/doc/imgs/00018069.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WenmuZhou/PytorchOCR/f899e9ddf953cbbcfb3f269318d0daa5ebcd2b53/doc/imgs/00018069.jpg
--------------------------------------------------------------------------------
/doc/imgs/00056221.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WenmuZhou/PytorchOCR/f899e9ddf953cbbcfb3f269318d0daa5ebcd2b53/doc/imgs/00056221.jpg
--------------------------------------------------------------------------------
/doc/imgs/00057937.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WenmuZhou/PytorchOCR/f899e9ddf953cbbcfb3f269318d0daa5ebcd2b53/doc/imgs/00057937.jpg
--------------------------------------------------------------------------------
/doc/imgs/00059985.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WenmuZhou/PytorchOCR/f899e9ddf953cbbcfb3f269318d0daa5ebcd2b53/doc/imgs/00059985.jpg
--------------------------------------------------------------------------------
/doc/imgs/00077949.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WenmuZhou/PytorchOCR/f899e9ddf953cbbcfb3f269318d0daa5ebcd2b53/doc/imgs/00077949.jpg
--------------------------------------------------------------------------------
/doc/imgs/00111002.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WenmuZhou/PytorchOCR/f899e9ddf953cbbcfb3f269318d0daa5ebcd2b53/doc/imgs/00111002.jpg
--------------------------------------------------------------------------------
/doc/imgs/00207393.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WenmuZhou/PytorchOCR/f899e9ddf953cbbcfb3f269318d0daa5ebcd2b53/doc/imgs/00207393.jpg
--------------------------------------------------------------------------------
/doc/imgs/1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WenmuZhou/PytorchOCR/f899e9ddf953cbbcfb3f269318d0daa5ebcd2b53/doc/imgs/1.jpg
--------------------------------------------------------------------------------
/doc/imgs/11.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WenmuZhou/PytorchOCR/f899e9ddf953cbbcfb3f269318d0daa5ebcd2b53/doc/imgs/11.jpg
--------------------------------------------------------------------------------
/doc/imgs/12.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WenmuZhou/PytorchOCR/f899e9ddf953cbbcfb3f269318d0daa5ebcd2b53/doc/imgs/12.jpg
--------------------------------------------------------------------------------
/doc/imgs/french_0.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WenmuZhou/PytorchOCR/f899e9ddf953cbbcfb3f269318d0daa5ebcd2b53/doc/imgs/french_0.jpg
--------------------------------------------------------------------------------
/doc/imgs/ger_1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WenmuZhou/PytorchOCR/f899e9ddf953cbbcfb3f269318d0daa5ebcd2b53/doc/imgs/ger_1.jpg
--------------------------------------------------------------------------------
/doc/imgs/ger_2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WenmuZhou/PytorchOCR/f899e9ddf953cbbcfb3f269318d0daa5ebcd2b53/doc/imgs/ger_2.jpg
--------------------------------------------------------------------------------
/doc/imgs/japan_1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WenmuZhou/PytorchOCR/f899e9ddf953cbbcfb3f269318d0daa5ebcd2b53/doc/imgs/japan_1.jpg
--------------------------------------------------------------------------------
/doc/imgs/japan_2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WenmuZhou/PytorchOCR/f899e9ddf953cbbcfb3f269318d0daa5ebcd2b53/doc/imgs/japan_2.jpg
--------------------------------------------------------------------------------
/doc/imgs/korean_1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WenmuZhou/PytorchOCR/f899e9ddf953cbbcfb3f269318d0daa5ebcd2b53/doc/imgs/korean_1.jpg
--------------------------------------------------------------------------------
/doc/imgs/model_prod_flow_ch.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WenmuZhou/PytorchOCR/f899e9ddf953cbbcfb3f269318d0daa5ebcd2b53/doc/imgs/model_prod_flow_ch.png
--------------------------------------------------------------------------------
/doc/imgs_words/arabic/ar_1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WenmuZhou/PytorchOCR/f899e9ddf953cbbcfb3f269318d0daa5ebcd2b53/doc/imgs_words/arabic/ar_1.jpg
--------------------------------------------------------------------------------
/doc/imgs_words/arabic/ar_2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WenmuZhou/PytorchOCR/f899e9ddf953cbbcfb3f269318d0daa5ebcd2b53/doc/imgs_words/arabic/ar_2.jpg
--------------------------------------------------------------------------------
/doc/imgs_words/belarusian/be_1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WenmuZhou/PytorchOCR/f899e9ddf953cbbcfb3f269318d0daa5ebcd2b53/doc/imgs_words/belarusian/be_1.jpg
--------------------------------------------------------------------------------
/doc/imgs_words/belarusian/be_2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WenmuZhou/PytorchOCR/f899e9ddf953cbbcfb3f269318d0daa5ebcd2b53/doc/imgs_words/belarusian/be_2.jpg
--------------------------------------------------------------------------------
/doc/imgs_words/bulgarian/bg_1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WenmuZhou/PytorchOCR/f899e9ddf953cbbcfb3f269318d0daa5ebcd2b53/doc/imgs_words/bulgarian/bg_1.jpg
--------------------------------------------------------------------------------
/doc/imgs_words/bulgarian/bg_2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WenmuZhou/PytorchOCR/f899e9ddf953cbbcfb3f269318d0daa5ebcd2b53/doc/imgs_words/bulgarian/bg_2.jpg
--------------------------------------------------------------------------------
/doc/imgs_words/ch/word_1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WenmuZhou/PytorchOCR/f899e9ddf953cbbcfb3f269318d0daa5ebcd2b53/doc/imgs_words/ch/word_1.jpg
--------------------------------------------------------------------------------
/doc/imgs_words/ch/word_2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WenmuZhou/PytorchOCR/f899e9ddf953cbbcfb3f269318d0daa5ebcd2b53/doc/imgs_words/ch/word_2.jpg
--------------------------------------------------------------------------------
/doc/imgs_words/ch/word_3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WenmuZhou/PytorchOCR/f899e9ddf953cbbcfb3f269318d0daa5ebcd2b53/doc/imgs_words/ch/word_3.jpg
--------------------------------------------------------------------------------
/doc/imgs_words/ch/word_4.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WenmuZhou/PytorchOCR/f899e9ddf953cbbcfb3f269318d0daa5ebcd2b53/doc/imgs_words/ch/word_4.jpg
--------------------------------------------------------------------------------
/doc/imgs_words/ch/word_5.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WenmuZhou/PytorchOCR/f899e9ddf953cbbcfb3f269318d0daa5ebcd2b53/doc/imgs_words/ch/word_5.jpg
--------------------------------------------------------------------------------
/doc/imgs_words/chinese_traditional/chinese_cht_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WenmuZhou/PytorchOCR/f899e9ddf953cbbcfb3f269318d0daa5ebcd2b53/doc/imgs_words/chinese_traditional/chinese_cht_1.png
--------------------------------------------------------------------------------
/doc/imgs_words/chinese_traditional/chinese_cht_2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WenmuZhou/PytorchOCR/f899e9ddf953cbbcfb3f269318d0daa5ebcd2b53/doc/imgs_words/chinese_traditional/chinese_cht_2.png
--------------------------------------------------------------------------------
/doc/imgs_words/en/word_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WenmuZhou/PytorchOCR/f899e9ddf953cbbcfb3f269318d0daa5ebcd2b53/doc/imgs_words/en/word_1.png
--------------------------------------------------------------------------------
/doc/imgs_words/en/word_2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WenmuZhou/PytorchOCR/f899e9ddf953cbbcfb3f269318d0daa5ebcd2b53/doc/imgs_words/en/word_2.png
--------------------------------------------------------------------------------
/doc/imgs_words/en/word_3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WenmuZhou/PytorchOCR/f899e9ddf953cbbcfb3f269318d0daa5ebcd2b53/doc/imgs_words/en/word_3.png
--------------------------------------------------------------------------------
/doc/imgs_words/en/word_4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WenmuZhou/PytorchOCR/f899e9ddf953cbbcfb3f269318d0daa5ebcd2b53/doc/imgs_words/en/word_4.png
--------------------------------------------------------------------------------
/doc/imgs_words/en/word_5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WenmuZhou/PytorchOCR/f899e9ddf953cbbcfb3f269318d0daa5ebcd2b53/doc/imgs_words/en/word_5.png
--------------------------------------------------------------------------------
/doc/imgs_words/french/1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WenmuZhou/PytorchOCR/f899e9ddf953cbbcfb3f269318d0daa5ebcd2b53/doc/imgs_words/french/1.jpg
--------------------------------------------------------------------------------
/doc/imgs_words/french/2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WenmuZhou/PytorchOCR/f899e9ddf953cbbcfb3f269318d0daa5ebcd2b53/doc/imgs_words/french/2.jpg
--------------------------------------------------------------------------------
/doc/imgs_words/german/1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WenmuZhou/PytorchOCR/f899e9ddf953cbbcfb3f269318d0daa5ebcd2b53/doc/imgs_words/german/1.jpg
--------------------------------------------------------------------------------
/doc/imgs_words/hindi/hi_1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WenmuZhou/PytorchOCR/f899e9ddf953cbbcfb3f269318d0daa5ebcd2b53/doc/imgs_words/hindi/hi_1.jpg
--------------------------------------------------------------------------------
/doc/imgs_words/hindi/hi_2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WenmuZhou/PytorchOCR/f899e9ddf953cbbcfb3f269318d0daa5ebcd2b53/doc/imgs_words/hindi/hi_2.jpg
--------------------------------------------------------------------------------
/doc/imgs_words/italian/it_1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WenmuZhou/PytorchOCR/f899e9ddf953cbbcfb3f269318d0daa5ebcd2b53/doc/imgs_words/italian/it_1.jpg
--------------------------------------------------------------------------------
/doc/imgs_words/italian/it_2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WenmuZhou/PytorchOCR/f899e9ddf953cbbcfb3f269318d0daa5ebcd2b53/doc/imgs_words/italian/it_2.jpg
--------------------------------------------------------------------------------
/doc/imgs_words/japan/1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WenmuZhou/PytorchOCR/f899e9ddf953cbbcfb3f269318d0daa5ebcd2b53/doc/imgs_words/japan/1.jpg
--------------------------------------------------------------------------------
/doc/imgs_words/kannada/ka_1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WenmuZhou/PytorchOCR/f899e9ddf953cbbcfb3f269318d0daa5ebcd2b53/doc/imgs_words/kannada/ka_1.jpg
--------------------------------------------------------------------------------
/doc/imgs_words/kannada/ka_2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WenmuZhou/PytorchOCR/f899e9ddf953cbbcfb3f269318d0daa5ebcd2b53/doc/imgs_words/kannada/ka_2.jpg
--------------------------------------------------------------------------------
/doc/imgs_words/korean/1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WenmuZhou/PytorchOCR/f899e9ddf953cbbcfb3f269318d0daa5ebcd2b53/doc/imgs_words/korean/1.jpg
--------------------------------------------------------------------------------
/doc/imgs_words/korean/2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WenmuZhou/PytorchOCR/f899e9ddf953cbbcfb3f269318d0daa5ebcd2b53/doc/imgs_words/korean/2.jpg
--------------------------------------------------------------------------------
/doc/imgs_words/marathi/mr_1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WenmuZhou/PytorchOCR/f899e9ddf953cbbcfb3f269318d0daa5ebcd2b53/doc/imgs_words/marathi/mr_1.jpg
--------------------------------------------------------------------------------
/doc/imgs_words/marathi/mr_2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WenmuZhou/PytorchOCR/f899e9ddf953cbbcfb3f269318d0daa5ebcd2b53/doc/imgs_words/marathi/mr_2.jpg
--------------------------------------------------------------------------------
/doc/imgs_words/nepali/ne_1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WenmuZhou/PytorchOCR/f899e9ddf953cbbcfb3f269318d0daa5ebcd2b53/doc/imgs_words/nepali/ne_1.jpg
--------------------------------------------------------------------------------
/doc/imgs_words/nepali/ne_2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WenmuZhou/PytorchOCR/f899e9ddf953cbbcfb3f269318d0daa5ebcd2b53/doc/imgs_words/nepali/ne_2.jpg
--------------------------------------------------------------------------------
/doc/imgs_words/occitan/oc_1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WenmuZhou/PytorchOCR/f899e9ddf953cbbcfb3f269318d0daa5ebcd2b53/doc/imgs_words/occitan/oc_1.jpg
--------------------------------------------------------------------------------
/doc/imgs_words/occitan/oc_2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WenmuZhou/PytorchOCR/f899e9ddf953cbbcfb3f269318d0daa5ebcd2b53/doc/imgs_words/occitan/oc_2.jpg
--------------------------------------------------------------------------------
/doc/imgs_words/persian/fa_1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WenmuZhou/PytorchOCR/f899e9ddf953cbbcfb3f269318d0daa5ebcd2b53/doc/imgs_words/persian/fa_1.jpg
--------------------------------------------------------------------------------
/doc/imgs_words/persian/fa_2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WenmuZhou/PytorchOCR/f899e9ddf953cbbcfb3f269318d0daa5ebcd2b53/doc/imgs_words/persian/fa_2.jpg
--------------------------------------------------------------------------------
/doc/imgs_words/portuguese/pu_1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WenmuZhou/PytorchOCR/f899e9ddf953cbbcfb3f269318d0daa5ebcd2b53/doc/imgs_words/portuguese/pu_1.jpg
--------------------------------------------------------------------------------
/doc/imgs_words/portuguese/pu_2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WenmuZhou/PytorchOCR/f899e9ddf953cbbcfb3f269318d0daa5ebcd2b53/doc/imgs_words/portuguese/pu_2.jpg
--------------------------------------------------------------------------------
/doc/imgs_words/russia/ru_1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WenmuZhou/PytorchOCR/f899e9ddf953cbbcfb3f269318d0daa5ebcd2b53/doc/imgs_words/russia/ru_1.jpg
--------------------------------------------------------------------------------
/doc/imgs_words/russia/ru_2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WenmuZhou/PytorchOCR/f899e9ddf953cbbcfb3f269318d0daa5ebcd2b53/doc/imgs_words/russia/ru_2.jpg
--------------------------------------------------------------------------------
/doc/imgs_words/serbian_cyrillic/rsc_1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WenmuZhou/PytorchOCR/f899e9ddf953cbbcfb3f269318d0daa5ebcd2b53/doc/imgs_words/serbian_cyrillic/rsc_1.jpg
--------------------------------------------------------------------------------
/doc/imgs_words/serbian_cyrillic/rsc_2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WenmuZhou/PytorchOCR/f899e9ddf953cbbcfb3f269318d0daa5ebcd2b53/doc/imgs_words/serbian_cyrillic/rsc_2.jpg
--------------------------------------------------------------------------------
/doc/imgs_words/serbian_latin/rs_1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WenmuZhou/PytorchOCR/f899e9ddf953cbbcfb3f269318d0daa5ebcd2b53/doc/imgs_words/serbian_latin/rs_1.jpg
--------------------------------------------------------------------------------
/doc/imgs_words/serbian_latin/rs_2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WenmuZhou/PytorchOCR/f899e9ddf953cbbcfb3f269318d0daa5ebcd2b53/doc/imgs_words/serbian_latin/rs_2.jpg
--------------------------------------------------------------------------------
/doc/imgs_words/spanish/xi_1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WenmuZhou/PytorchOCR/f899e9ddf953cbbcfb3f269318d0daa5ebcd2b53/doc/imgs_words/spanish/xi_1.jpg
--------------------------------------------------------------------------------
/doc/imgs_words/spanish/xi_2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WenmuZhou/PytorchOCR/f899e9ddf953cbbcfb3f269318d0daa5ebcd2b53/doc/imgs_words/spanish/xi_2.jpg
--------------------------------------------------------------------------------
/doc/imgs_words/tamil/ta_1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WenmuZhou/PytorchOCR/f899e9ddf953cbbcfb3f269318d0daa5ebcd2b53/doc/imgs_words/tamil/ta_1.jpg
--------------------------------------------------------------------------------
/doc/imgs_words/tamil/ta_2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WenmuZhou/PytorchOCR/f899e9ddf953cbbcfb3f269318d0daa5ebcd2b53/doc/imgs_words/tamil/ta_2.jpg
--------------------------------------------------------------------------------
/doc/imgs_words/telugu/te_1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WenmuZhou/PytorchOCR/f899e9ddf953cbbcfb3f269318d0daa5ebcd2b53/doc/imgs_words/telugu/te_1.jpg
--------------------------------------------------------------------------------
/doc/imgs_words/telugu/te_2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WenmuZhou/PytorchOCR/f899e9ddf953cbbcfb3f269318d0daa5ebcd2b53/doc/imgs_words/telugu/te_2.jpg
--------------------------------------------------------------------------------
/doc/imgs_words/ukranian/uk_1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WenmuZhou/PytorchOCR/f899e9ddf953cbbcfb3f269318d0daa5ebcd2b53/doc/imgs_words/ukranian/uk_1.jpg
--------------------------------------------------------------------------------
/doc/imgs_words/ukranian/uk_2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WenmuZhou/PytorchOCR/f899e9ddf953cbbcfb3f269318d0daa5ebcd2b53/doc/imgs_words/ukranian/uk_2.jpg
--------------------------------------------------------------------------------
/doc/imgs_words/urdu/ur_1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WenmuZhou/PytorchOCR/f899e9ddf953cbbcfb3f269318d0daa5ebcd2b53/doc/imgs_words/urdu/ur_1.jpg
--------------------------------------------------------------------------------
/doc/imgs_words/urdu/ur_2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WenmuZhou/PytorchOCR/f899e9ddf953cbbcfb3f269318d0daa5ebcd2b53/doc/imgs_words/urdu/ur_2.jpg
--------------------------------------------------------------------------------
/doc/imgs_words/uyghur/ug_1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WenmuZhou/PytorchOCR/f899e9ddf953cbbcfb3f269318d0daa5ebcd2b53/doc/imgs_words/uyghur/ug_1.jpg
--------------------------------------------------------------------------------
/doc/imgs_words/uyghur/ug_2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WenmuZhou/PytorchOCR/f899e9ddf953cbbcfb3f269318d0daa5ebcd2b53/doc/imgs_words/uyghur/ug_2.jpg
--------------------------------------------------------------------------------
/padiff/abstracts/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2023 PaddlePaddle Authors. All Rights Reserved.
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | from .proxy_model import ProxyModel
16 |
--------------------------------------------------------------------------------
/padiff/abstracts/proxy_utils.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2023 PaddlePaddle Authors. All Rights Reserved.
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 |
16 | def init_route(model):
17 | def _set_route(model, path):
18 | for name, child in model.named_children():
19 | path.append(name)
20 | if not hasattr(child.model, "route"):
21 | setattr(child.model, "route", ".".join(path))
22 | _set_route(child, path)
23 | path.pop()
24 |
25 | if not hasattr(model, "route"):
26 | setattr(model.model, "route", model.name)
27 | _set_route(model, [model.name])
28 |
29 |
30 | def remove_inplace(model):
31 | """
32 | Set `inplace` tag to `False` for torch module
33 | """
34 | for submodel in model.submodels():
35 | if hasattr(submodel, "inplace"):
36 | submodel.inplace = False
37 |
38 |
39 | def deco_iter(iterator, fn):
40 | def new_fn(obj):
41 | try:
42 | return fn(obj)
43 | except:
44 | return obj
45 |
46 | def new_generator():
47 | for obj in iterator:
48 | if isinstance(obj, (tuple, list)):
49 | yield tuple(map(new_fn, obj))
50 | else:
51 | yield new_fn(obj)
52 |
53 | return new_generator()
54 |
--------------------------------------------------------------------------------
/padiff/checker/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2023 PaddlePaddle Authors. All Rights Reserved.
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | from .check_report import check_report
16 | from .check_params import check_params, check_weights, check_grads
17 | from .checker_utils import update_configs, global_compare_configs
18 |
--------------------------------------------------------------------------------
/padiff/datas/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2023 PaddlePaddle Authors. All Rights Reserved.
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | from .file_loader import global_json_laoder, global_yaml_loader
16 |
--------------------------------------------------------------------------------
/padiff/datas/assign_weight.yaml:
--------------------------------------------------------------------------------
1 | Linear:
2 | torch:
3 | - Linear
4 | - NonDynamicallyQuantizableLinear
5 | param:
6 | weight: transpose
7 |
--------------------------------------------------------------------------------
/padiff/interfaces/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2023 PaddlePaddle Authors. All Rights Reserved.
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | # this folder is used for support user interfaces
16 |
17 | from .interfaces import create_model, assign_weight, auto_diff, check_dataloader
18 | from ..checker import check_report, check_params, check_grads, check_weights
19 | from ..dump_tools import set_dump_root_path, get_dump_root_path
20 | from ..weight_init.special_init import add_special_init
21 |
--------------------------------------------------------------------------------
/padiff/report/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2023 PaddlePaddle Authors. All Rights Reserved.
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | from .report import Report, report_guard, current_report
16 | from .hooks import register_hooker, SyncStepGuard, single_step_state
17 |
--------------------------------------------------------------------------------
/padiff/weight_init/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2023 PaddlePaddle Authors. All Rights Reserved.
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | # this folder is just used to support assign_weight interface
16 |
17 | from .weights import assign_weight_
18 |
--------------------------------------------------------------------------------
/padiff/weight_init/special_init/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | from .special_init_pool import global_special_init_pool, add_special_init, build_name
16 |
17 | import os
18 | import importlib
19 |
20 | cur_dir = os.path.split(os.path.realpath(__file__))[0]
21 | for filename in os.listdir(cur_dir):
22 | if filename.startswith("init_") and filename.endswith(".py"):
23 | module_name = filename.rpartition(".")[0]
24 | importlib.import_module(__name__ + "." + module_name)
25 |
26 | __all__ = [
27 | "global_special_init_pool",
28 | "add_special_init",
29 | "build_name",
30 | ]
31 |
--------------------------------------------------------------------------------
/padiff/weight_init/special_init/init_BatchNorm2D.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | import paddle
16 | import torch
17 |
18 | from .special_init_pool import global_special_init_pool as init_pool
19 |
20 |
21 | @init_pool.register("torch", "BatchNorm2d", "paddle", "BatchNorm2D")
22 | def init_BatchNorm2D(module, layer):
23 | param_dict = {}
24 | for name, param in layer.state_dict().items():
25 | name = name.replace("_variance", "running_var").replace("_mean", "running_mean")
26 | param_dict[name] = torch.from_numpy(param.cpu().detach().numpy())
27 | module.load_state_dict(param_dict)
28 |
29 | @init_pool.register("torch", "BatchNorm2d", "paddle", "BatchNorm")
30 | def init_BatchNorm2D(module, layer):
31 | param_dict = {}
32 | for name, param in layer.state_dict().items():
33 | name = name.replace("_variance", "running_var").replace("_mean", "running_mean")
34 | param_dict[name] = torch.from_numpy(param.cpu().detach().numpy())
35 | module.load_state_dict(param_dict)
--------------------------------------------------------------------------------
/padiff/weight_init/special_init/init_Embeddings.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | import paddle
16 | import torch
17 |
18 | from .special_init_pool import global_special_init_pool as init_pool
19 |
20 |
21 | @init_pool.register("torch", "Embeddings", "paddle", "Embeddings")
22 | def init_Embeddings(module, layer):
23 | param_dict = {}
24 | for name, param in layer.state_dict().items():
25 | param_dict[name] = torch.from_numpy(param.cpu().detach().numpy())
26 | module.load_state_dict(param_dict)
--------------------------------------------------------------------------------
/padiff/weight_init/special_init/init_LSTM.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 | import torch
15 |
16 | from .special_init_pool import global_special_init_pool as init_pool
17 | import paddle
18 |
19 |
20 | @init_pool.register("torch", "LSTM", "paddle", "LSTM")
21 | def init_LSTM(module, layer):
22 | for (name, paddle_param), torch_param in zip(
23 | layer.named_parameters(prefix="", include_sublayers=False),
24 | module.parameters(recurse=False),
25 | ):
26 | p_shape = list(paddle_param.shape)
27 | t_shape = list(torch_param.shape)
28 |
29 | assert p_shape == t_shape, ("While init LSTM, shape of param `{}` is not the same. {} vs {}\n").format(
30 | name, p_shape, t_shape
31 | )
32 | np_value = paddle_param.detach().cpu().numpy()
33 | torch_param.data = torch.from_numpy(np_value)
34 |
--------------------------------------------------------------------------------
/ppocr/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved.
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
--------------------------------------------------------------------------------
/ppocr/data/imaug/ColorJitter.py:
--------------------------------------------------------------------------------
1 | # copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve.
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 | from paddle.vision.transforms import ColorJitter as pp_ColorJitter
15 |
16 | __all__ = ['ColorJitter']
17 |
18 | class ColorJitter(object):
19 | def __init__(self, brightness=0, contrast=0, saturation=0, hue=0,**kwargs):
20 | self.aug = pp_ColorJitter(brightness, contrast, saturation, hue)
21 |
22 | def __call__(self, data):
23 | image = data['image']
24 | image = self.aug(image)
25 | data['image'] = image
26 | return data
27 |
--------------------------------------------------------------------------------
/ppocr/data/imaug/text_image_aug/__init__.py:
--------------------------------------------------------------------------------
1 | # copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve.
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | from .augment import tia_perspective, tia_distort, tia_stretch
16 |
17 | __all__ = ['tia_distort', 'tia_stretch', 'tia_perspective']
18 |
--------------------------------------------------------------------------------
/ppocr/data/imaug/vqa/__init__.py:
--------------------------------------------------------------------------------
1 | # copyright (c) 2021 PaddlePaddle Authors. All Rights Reserve.
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | from .token import VQATokenPad, VQASerTokenChunk, VQAReTokenChunk, VQAReTokenRelation, TensorizeEntitiesRelations
16 |
17 | __all__ = [
18 | 'VQATokenPad', 'VQASerTokenChunk', 'VQAReTokenChunk', 'VQAReTokenRelation',
19 | 'TensorizeEntitiesRelations'
20 | ]
21 |
--------------------------------------------------------------------------------
/ppocr/data/imaug/vqa/augment.py:
--------------------------------------------------------------------------------
1 | # copyright (c) 2022 PaddlePaddle Authors. All Rights Reserve.
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | import os
16 | import sys
17 | import numpy as np
18 | import random
19 | from copy import deepcopy
20 |
21 |
22 | def order_by_tbyx(ocr_info):
23 | res = sorted(ocr_info, key=lambda r: (r["bbox"][1], r["bbox"][0]))
24 | for i in range(len(res) - 1):
25 | for j in range(i, 0, -1):
26 | if abs(res[j + 1]["bbox"][1] - res[j]["bbox"][1]) < 20 and \
27 | (res[j + 1]["bbox"][0] < res[j]["bbox"][0]):
28 | tmp = deepcopy(res[j])
29 | res[j] = deepcopy(res[j + 1])
30 | res[j + 1] = deepcopy(tmp)
31 | else:
32 | break
33 | return res
34 |
--------------------------------------------------------------------------------
/ppocr/data/imaug/vqa/token/__init__.py:
--------------------------------------------------------------------------------
1 | # copyright (c) 2021 PaddlePaddle Authors. All Rights Reserve.
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | from .vqa_token_chunk import VQASerTokenChunk, VQAReTokenChunk
16 | from .vqa_token_pad import VQATokenPad
17 | from .vqa_token_relation import VQAReTokenRelation
18 | from .vqa_re_convert import TensorizeEntitiesRelations
--------------------------------------------------------------------------------
/ppocr/ext_op/__init__.py:
--------------------------------------------------------------------------------
1 | from .roi_align_rotated.roi_align_rotated import RoIAlignRotated
2 |
--------------------------------------------------------------------------------
/ppocr/losses/ace_loss.py:
--------------------------------------------------------------------------------
1 | # copyright (c) 2021 PaddlePaddle Authors. All Rights Reserve.
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | # This code is refer from: https://github.com/viig99/LS-ACELoss
16 |
17 | from __future__ import absolute_import
18 | from __future__ import division
19 | from __future__ import print_function
20 |
21 | import paddle
22 | import paddle.nn as nn
23 |
24 |
25 | class ACELoss(nn.Layer):
26 | def __init__(self, **kwargs):
27 | super().__init__()
28 | self.loss_func = nn.CrossEntropyLoss(
29 | weight=None,
30 | ignore_index=0,
31 | reduction='none',
32 | soft_label=True,
33 | axis=-1)
34 |
35 | def __call__(self, predicts, batch):
36 | if isinstance(predicts, (list, tuple)):
37 | predicts = predicts[-1]
38 |
39 | B, N = predicts.shape[:2]
40 | div = paddle.to_tensor([N]).astype('float32')
41 |
42 | predicts = nn.functional.softmax(predicts, axis=-1)
43 | aggregation_preds = paddle.sum(predicts, axis=1)
44 | aggregation_preds = paddle.divide(aggregation_preds, div)
45 |
46 | length = batch[2].astype("float32")
47 | batch = batch[3].astype("float32")
48 | batch[:, 0] = paddle.subtract(div, length)
49 | batch = paddle.divide(batch, div)
50 |
51 | loss = self.loss_func(aggregation_preds, batch)
52 | return {"loss_ace": loss}
53 |
--------------------------------------------------------------------------------
/ppocr/losses/cls_loss.py:
--------------------------------------------------------------------------------
1 | # copyright (c) 2019 PaddlePaddle Authors. All Rights Reserve.
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | from __future__ import absolute_import
16 | from __future__ import division
17 | from __future__ import print_function
18 |
19 | from paddle import nn
20 |
21 |
22 | class ClsLoss(nn.Layer):
23 | def __init__(self, **kwargs):
24 | super(ClsLoss, self).__init__()
25 | self.loss_func = nn.CrossEntropyLoss(reduction='mean')
26 |
27 | def forward(self, predicts, batch):
28 | label = batch[1].astype("int64")
29 | loss = self.loss_func(input=predicts, label=label)
30 | return {'loss': loss}
31 |
--------------------------------------------------------------------------------
/ppocr/losses/rec_att_loss.py:
--------------------------------------------------------------------------------
1 | # copyright (c) 2021 PaddlePaddle Authors. All Rights Reserve.
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | from __future__ import absolute_import
16 | from __future__ import division
17 | from __future__ import print_function
18 |
19 | import paddle
20 | from paddle import nn
21 |
22 |
23 | class AttentionLoss(nn.Layer):
24 | def __init__(self, **kwargs):
25 | super(AttentionLoss, self).__init__()
26 | self.loss_func = nn.CrossEntropyLoss(weight=None, reduction='none')
27 |
28 | def forward(self, predicts, batch):
29 | targets = batch[1].astype("int64")
30 | label_lengths = batch[2].astype('int64')
31 | batch_size, num_steps, num_classes = predicts.shape[0], predicts.shape[
32 | 1], predicts.shape[2]
33 | assert len(targets.shape) == len(list(predicts.shape)) - 1, \
34 | "The target's shape and inputs's shape is [N, d] and [N, num_steps]"
35 |
36 | inputs = paddle.reshape(predicts, [-1, predicts.shape[-1]])
37 | targets = paddle.reshape(targets, [-1])
38 |
39 | return {'loss': paddle.sum(self.loss_func(inputs, targets))}
40 |
--------------------------------------------------------------------------------
/ppocr/losses/rec_ctc_loss.py:
--------------------------------------------------------------------------------
1 | # copyright (c) 2019 PaddlePaddle Authors. All Rights Reserve.
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | from __future__ import absolute_import
16 | from __future__ import division
17 | from __future__ import print_function
18 |
19 | import paddle
20 | from paddle import nn
21 |
22 |
23 | class CTCLoss(nn.Layer):
24 | def __init__(self, use_focal_loss=False, **kwargs):
25 | super(CTCLoss, self).__init__()
26 | self.loss_func = nn.CTCLoss(blank=0, reduction='none')
27 | self.use_focal_loss = use_focal_loss
28 |
29 | def forward(self, predicts, batch):
30 | if isinstance(predicts, (list, tuple)):
31 | predicts = predicts[-1]
32 | predicts = predicts.transpose((1, 0, 2))
33 | N, B, _ = predicts.shape
34 | preds_lengths = paddle.to_tensor(
35 | [N] * B, dtype='int64', place=paddle.CPUPlace())
36 | labels = batch[1].astype("int32")
37 | label_lengths = batch[2].astype('int64')
38 | loss = self.loss_func(predicts, labels, preds_lengths, label_lengths)
39 | if self.use_focal_loss:
40 | weight = paddle.exp(-loss)
41 | weight = paddle.subtract(paddle.to_tensor([1.0]), weight)
42 | weight = paddle.square(weight)
43 | loss = paddle.multiply(loss, weight)
44 | loss = loss.mean()
45 | return {'loss': loss}
46 |
--------------------------------------------------------------------------------
/ppocr/losses/rec_nrtr_loss.py:
--------------------------------------------------------------------------------
1 | import paddle
2 | from paddle import nn
3 | import paddle.nn.functional as F
4 |
5 |
6 | class NRTRLoss(nn.Layer):
7 | def __init__(self, smoothing=True, ignore_index=0, **kwargs):
8 | super(NRTRLoss, self).__init__()
9 | if ignore_index >= 0 and not smoothing:
10 | self.loss_func = nn.CrossEntropyLoss(
11 | reduction='mean', ignore_index=ignore_index)
12 | self.smoothing = smoothing
13 |
14 | def forward(self, pred, batch):
15 | max_len = batch[2].max()
16 | tgt = batch[1][:, 1:2 + max_len]
17 | pred = pred.reshape([-1, pred.shape[2]])
18 | tgt = tgt.reshape([-1])
19 | if self.smoothing:
20 | eps = 0.1
21 | n_class = pred.shape[1]
22 | one_hot = F.one_hot(tgt, pred.shape[1])
23 | one_hot = one_hot * (1 - eps) + (1 - one_hot) * eps / (n_class - 1)
24 | log_prb = F.log_softmax(pred, axis=1)
25 | non_pad_mask = paddle.not_equal(
26 | tgt, paddle.zeros(
27 | tgt.shape, dtype=tgt.dtype))
28 | loss = -(one_hot * log_prb).sum(axis=1)
29 | loss = loss.masked_select(non_pad_mask).mean()
30 | else:
31 | loss = self.loss_func(pred, tgt)
32 | return {'loss': loss}
33 |
--------------------------------------------------------------------------------
/ppocr/losses/rec_pren_loss.py:
--------------------------------------------------------------------------------
1 | # copyright (c) 2022 PaddlePaddle Authors. All Rights Reserve.
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | from __future__ import absolute_import
16 | from __future__ import division
17 | from __future__ import print_function
18 |
19 | from paddle import nn
20 |
21 |
22 | class PRENLoss(nn.Layer):
23 | def __init__(self, **kwargs):
24 | super(PRENLoss, self).__init__()
25 | # note: 0 is padding idx
26 | self.loss_func = nn.CrossEntropyLoss(reduction='mean', ignore_index=0)
27 |
28 | def forward(self, predicts, batch):
29 | loss = self.loss_func(predicts, batch[1].astype('int64'))
30 | return {'loss': loss}
31 |
--------------------------------------------------------------------------------
/ppocr/losses/rec_sar_loss.py:
--------------------------------------------------------------------------------
1 | from __future__ import absolute_import
2 | from __future__ import division
3 | from __future__ import print_function
4 |
5 | import paddle
6 | from paddle import nn
7 |
8 |
9 | class SARLoss(nn.Layer):
10 | def __init__(self, **kwargs):
11 | super(SARLoss, self).__init__()
12 | ignore_index = kwargs.get('ignore_index', 92) # 6626
13 | self.loss_func = paddle.nn.loss.CrossEntropyLoss(
14 | reduction="mean", ignore_index=ignore_index)
15 |
16 | def forward(self, predicts, batch):
17 | predict = predicts[:, :
18 | -1, :] # ignore last index of outputs to be in same seq_len with targets
19 | label = batch[1].astype(
20 | "int64")[:, 1:] # ignore first index of target in loss calculation
21 | batch_size, num_steps, num_classes = predict.shape[0], predict.shape[
22 | 1], predict.shape[2]
23 | assert len(label.shape) == len(list(predict.shape)) - 1, \
24 | "The target's shape and inputs's shape is [N, d] and [N, num_steps]"
25 |
26 | inputs = paddle.reshape(predict, [-1, num_classes])
27 | targets = paddle.reshape(label, [-1])
28 | loss = self.loss_func(inputs, targets)
29 | return {'loss': loss}
30 |
--------------------------------------------------------------------------------
/ppocr/losses/rec_satrn_loss.py:
--------------------------------------------------------------------------------
1 | # copyright (c) 2022 PaddlePaddle Authors. All Rights Reserve.
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 | """
15 | This code is refer from:
16 | https://github.com/open-mmlab/mmocr/blob/1.x/mmocr/models/textrecog/module_losses/ce_module_loss.py
17 | """
18 | from __future__ import absolute_import
19 | from __future__ import division
20 | from __future__ import print_function
21 |
22 | import paddle
23 | from paddle import nn
24 |
25 |
26 | class SATRNLoss(nn.Layer):
27 | def __init__(self, **kwargs):
28 | super(SATRNLoss, self).__init__()
29 | ignore_index = kwargs.get('ignore_index', 92) # 6626
30 | self.loss_func = paddle.nn.loss.CrossEntropyLoss(
31 | reduction="none", ignore_index=ignore_index)
32 |
33 | def forward(self, predicts, batch):
34 | predict = predicts[:, :
35 | -1, :] # ignore last index of outputs to be in same seq_len with targets
36 | label = batch[1].astype(
37 | "int64")[:, 1:] # ignore first index of target in loss calculation
38 | batch_size, num_steps, num_classes = predict.shape[0], predict.shape[
39 | 1], predict.shape[2]
40 | assert len(label.shape) == len(list(predict.shape)) - 1, \
41 | "The target's shape and inputs's shape is [N, d] and [N, num_steps]"
42 |
43 | inputs = paddle.reshape(predict, [-1, num_classes])
44 | targets = paddle.reshape(label, [-1])
45 | loss = self.loss_func(inputs, targets)
46 | return {'loss': loss.mean()}
47 |
--------------------------------------------------------------------------------
/ppocr/losses/rec_spin_att_loss.py:
--------------------------------------------------------------------------------
1 | # copyright (c) 2022 PaddlePaddle Authors. All Rights Reserve.
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 |
16 | from __future__ import absolute_import
17 | from __future__ import division
18 | from __future__ import print_function
19 |
20 | import paddle
21 | from paddle import nn
22 |
23 | '''This code is refer from:
24 | https://github.com/hikopensource/DAVAR-Lab-OCR
25 | '''
26 |
27 | class SPINAttentionLoss(nn.Layer):
28 | def __init__(self, reduction='mean', ignore_index=-100, **kwargs):
29 | super(SPINAttentionLoss, self).__init__()
30 | self.loss_func = nn.CrossEntropyLoss(weight=None, reduction=reduction, ignore_index=ignore_index)
31 |
32 | def forward(self, predicts, batch):
33 | targets = batch[1].astype("int64")
34 | targets = targets[:, 1:] # remove [eos] in label
35 |
36 | label_lengths = batch[2].astype('int64')
37 | batch_size, num_steps, num_classes = predicts.shape[0], predicts.shape[
38 | 1], predicts.shape[2]
39 | assert len(targets.shape) == len(list(predicts.shape)) - 1, \
40 | "The target's shape and inputs's shape is [N, d] and [N, num_steps]"
41 |
42 | inputs = paddle.reshape(predicts, [-1, predicts.shape[-1]])
43 | targets = paddle.reshape(targets, [-1])
44 |
45 | return {'loss': self.loss_func(inputs, targets)}
46 |
--------------------------------------------------------------------------------
/ppocr/losses/rec_srn_loss.py:
--------------------------------------------------------------------------------
1 | # copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve.
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | from __future__ import absolute_import
16 | from __future__ import division
17 | from __future__ import print_function
18 |
19 | import paddle
20 | from paddle import nn
21 |
22 |
23 | class SRNLoss(nn.Layer):
24 | def __init__(self, **kwargs):
25 | super(SRNLoss, self).__init__()
26 | self.loss_func = paddle.nn.loss.CrossEntropyLoss(reduction="sum")
27 |
28 | def forward(self, predicts, batch):
29 | predict = predicts['predict']
30 | word_predict = predicts['word_out']
31 | gsrm_predict = predicts['gsrm_out']
32 | label = batch[1]
33 |
34 | casted_label = paddle.cast(x=label, dtype='int64')
35 | casted_label = paddle.reshape(x=casted_label, shape=[-1, 1])
36 |
37 | cost_word = self.loss_func(word_predict, label=casted_label)
38 | cost_gsrm = self.loss_func(gsrm_predict, label=casted_label)
39 | cost_vsfd = self.loss_func(predict, label=casted_label)
40 |
41 | cost_word = paddle.reshape(x=paddle.sum(cost_word), shape=[1])
42 | cost_gsrm = paddle.reshape(x=paddle.sum(cost_gsrm), shape=[1])
43 | cost_vsfd = paddle.reshape(x=paddle.sum(cost_vsfd), shape=[1])
44 |
45 | sum_cost = cost_word * 3.0 + cost_vsfd + cost_gsrm * 0.15
46 |
47 | return {'loss': sum_cost, 'word_loss': cost_word, 'img_loss': cost_vsfd}
48 |
--------------------------------------------------------------------------------
/ppocr/losses/vqa_token_layoutlm_loss.py:
--------------------------------------------------------------------------------
1 | # copyright (c) 2021 PaddlePaddle Authors. All Rights Reserve.
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | from __future__ import absolute_import
16 | from __future__ import division
17 | from __future__ import print_function
18 |
19 | from paddle import nn
20 | from ppocr.losses.basic_loss import DMLLoss
21 |
22 |
23 | class VQASerTokenLayoutLMLoss(nn.Layer):
24 | def __init__(self, num_classes, key=None):
25 | super().__init__()
26 | self.loss_class = nn.CrossEntropyLoss()
27 | self.num_classes = num_classes
28 | self.ignore_index = self.loss_class.ignore_index
29 | self.key = key
30 |
31 | def forward(self, predicts, batch):
32 | if isinstance(predicts, dict) and self.key is not None:
33 | predicts = predicts[self.key]
34 | labels = batch[5]
35 | attention_mask = batch[2]
36 | if attention_mask is not None:
37 | active_loss = attention_mask.reshape([-1, ]) == 1
38 | active_output = predicts.reshape(
39 | [-1, self.num_classes])[active_loss]
40 | active_label = labels.reshape([-1, ])[active_loss]
41 | loss = self.loss_class(active_output, active_label)
42 | else:
43 | loss = self.loss_class(
44 | predicts.reshape([-1, self.num_classes]),
45 | labels.reshape([-1, ]))
46 | return {'loss': loss}
--------------------------------------------------------------------------------
/ppocr/metrics/__init__.py:
--------------------------------------------------------------------------------
1 | # copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve.
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | from __future__ import absolute_import
16 | from __future__ import division
17 | from __future__ import print_function
18 | from __future__ import unicode_literals
19 |
20 | import copy
21 |
22 | __all__ = ["build_metric"]
23 |
24 | from .det_metric import DetMetric, DetFCEMetric
25 | from .rec_metric import RecMetric, CNTMetric, CANMetric
26 | from .cls_metric import ClsMetric
27 | from .e2e_metric import E2EMetric
28 | from .distillation_metric import DistillationMetric
29 | from .table_metric import TableMetric
30 | from .kie_metric import KIEMetric
31 | from .vqa_token_ser_metric import VQASerTokenMetric
32 | from .vqa_token_re_metric import VQAReTokenMetric
33 | from .sr_metric import SRMetric
34 | from .ct_metric import CTMetric
35 |
36 |
37 | def build_metric(config):
38 | support_dict = [
39 | "DetMetric", "DetFCEMetric", "RecMetric", "ClsMetric", "E2EMetric",
40 | "DistillationMetric", "TableMetric", 'KIEMetric', 'VQASerTokenMetric',
41 | 'VQAReTokenMetric', 'SRMetric', 'CTMetric', 'CNTMetric', 'CANMetric'
42 | ]
43 |
44 | config = copy.deepcopy(config)
45 | module_name = config.pop("name")
46 | assert module_name in support_dict, Exception(
47 | "metric only support {}".format(support_dict))
48 | module_class = eval(module_name)(**config)
49 | return module_class
50 |
--------------------------------------------------------------------------------
/ppocr/metrics/cls_metric.py:
--------------------------------------------------------------------------------
1 | # copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve.
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 |
16 | class ClsMetric(object):
17 | def __init__(self, main_indicator='acc', **kwargs):
18 | self.main_indicator = main_indicator
19 | self.eps = 1e-5
20 | self.reset()
21 |
22 | def __call__(self, pred_label, *args, **kwargs):
23 | preds, labels = pred_label
24 | correct_num = 0
25 | all_num = 0
26 | for (pred, pred_conf), (target, _) in zip(preds, labels):
27 | if pred == target:
28 | correct_num += 1
29 | all_num += 1
30 | self.correct_num += correct_num
31 | self.all_num += all_num
32 | return {'acc': correct_num / (all_num + self.eps), }
33 |
34 | def get_metric(self):
35 | """
36 | return metrics {
37 | 'acc': 0
38 | }
39 | """
40 | acc = self.correct_num / (self.all_num + self.eps)
41 | self.reset()
42 | return {'acc': acc}
43 |
44 | def reset(self):
45 | self.correct_num = 0
46 | self.all_num = 0
47 |
--------------------------------------------------------------------------------
/ppocr/metrics/ct_metric.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved.
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | from __future__ import absolute_import
16 | from __future__ import division
17 | from __future__ import print_function
18 |
19 | import os
20 | from scipy import io
21 | import numpy as np
22 |
23 | from ppocr.utils.e2e_metric.Deteval import combine_results, get_score_C
24 |
25 |
26 | class CTMetric(object):
27 | def __init__(self, main_indicator, delimiter='\t', **kwargs):
28 | self.delimiter = delimiter
29 | self.main_indicator = main_indicator
30 | self.reset()
31 |
32 | def reset(self):
33 | self.results = [] # clear results
34 |
35 | def __call__(self, preds, batch, **kwargs):
36 | # NOTE: only support bs=1 now, as the label length of different sample is Unequal
37 | assert len(
38 | preds) == 1, "CentripetalText test now only suuport batch_size=1."
39 | label = batch[2]
40 | text = batch[3]
41 | pred = preds[0]['points']
42 | result = get_score_C(label, text, pred)
43 |
44 | self.results.append(result)
45 |
46 | def get_metric(self):
47 | """
48 | Input format: y0,x0, ..... yn,xn. Each detection is separated by the end of line token ('\n')'
49 | """
50 | metrics = combine_results(self.results, rec_flag=False)
51 | self.reset()
52 | return metrics
53 |
--------------------------------------------------------------------------------
/ppocr/metrics/vqa_token_ser_metric.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved.
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | from __future__ import absolute_import
16 | from __future__ import division
17 | from __future__ import print_function
18 |
19 | import numpy as np
20 | import paddle
21 |
22 | __all__ = ['KIEMetric']
23 |
24 |
25 | class VQASerTokenMetric(object):
26 | def __init__(self, main_indicator='hmean', **kwargs):
27 | self.main_indicator = main_indicator
28 | self.reset()
29 |
30 | def __call__(self, preds, batch, **kwargs):
31 | preds, labels = preds
32 | self.pred_list.extend(preds)
33 | self.gt_list.extend(labels)
34 |
35 | def get_metric(self):
36 | from seqeval.metrics import f1_score, precision_score, recall_score
37 | metrics = {
38 | "precision": precision_score(self.gt_list, self.pred_list),
39 | "recall": recall_score(self.gt_list, self.pred_list),
40 | "hmean": f1_score(self.gt_list, self.pred_list),
41 | }
42 | self.reset()
43 | return metrics
44 |
45 | def reset(self):
46 | self.pred_list = []
47 | self.gt_list = []
48 |
--------------------------------------------------------------------------------
/ppocr/modeling/architectures/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved.
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | import copy
16 | import importlib
17 |
18 | from .base_model import BaseModel
19 | from .distillation_model import DistillationModel
20 |
21 | __all__ = ["build_model"]
22 |
23 |
24 | def build_model(config):
25 | config = copy.deepcopy(config)
26 | if not "name" in config:
27 | arch = BaseModel(config)
28 | else:
29 | name = config.pop("name")
30 | mod = importlib.import_module(__name__)
31 | arch = getattr(mod, name)(config)
32 | return arch
--------------------------------------------------------------------------------
/ppocr/modeling/backbones/rec_nrtr_mtb.py:
--------------------------------------------------------------------------------
1 | # copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve.
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | from paddle import nn
16 | import paddle
17 |
18 |
19 | class MTB(nn.Layer):
20 | def __init__(self, cnn_num, in_channels):
21 | super(MTB, self).__init__()
22 | self.block = nn.Sequential()
23 | self.out_channels = in_channels
24 | self.cnn_num = cnn_num
25 | if self.cnn_num == 2:
26 | for i in range(self.cnn_num):
27 | self.block.add_sublayer(
28 | 'conv_{}'.format(i),
29 | nn.Conv2D(
30 | in_channels=in_channels
31 | if i == 0 else 32 * (2**(i - 1)),
32 | out_channels=32 * (2**i),
33 | kernel_size=3,
34 | stride=2,
35 | padding=1))
36 | self.block.add_sublayer('relu_{}'.format(i), nn.ReLU())
37 | self.block.add_sublayer('bn_{}'.format(i),
38 | nn.BatchNorm2D(32 * (2**i)))
39 |
40 | def forward(self, images):
41 | x = self.block(images)
42 | if self.cnn_num == 2:
43 | # (b, w, h, c)
44 | x = paddle.transpose(x, [0, 3, 2, 1])
45 | x_shape = paddle.shape(x)
46 | x = paddle.reshape(
47 | x, [x_shape[0], x_shape[1], x_shape[2] * x_shape[3]])
48 | return x
49 |
--------------------------------------------------------------------------------
/ppocr/modeling/heads/cls_head.py:
--------------------------------------------------------------------------------
1 | # copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve.
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | from __future__ import absolute_import
16 | from __future__ import division
17 | from __future__ import print_function
18 |
19 | import math
20 | import paddle
21 | from paddle import nn, ParamAttr
22 | import paddle.nn.functional as F
23 |
24 |
25 | class ClsHead(nn.Layer):
26 | """
27 | Class orientation
28 |
29 | Args:
30 |
31 | params(dict): super parameters for build Class network
32 | """
33 |
34 | def __init__(self, in_channels, class_dim, **kwargs):
35 | super(ClsHead, self).__init__()
36 | self.pool = nn.AdaptiveAvgPool2D(1)
37 | self.fc = nn.Linear(
38 | in_channels,
39 | class_dim)
40 |
41 | def forward(self, x, targets=None):
42 | x = self.pool(x)
43 | x = paddle.reshape(x, shape=[x.shape[0], x.shape[1]])
44 | x = self.fc(x)
45 | if not self.training:
46 | x = F.softmax(x, axis=1)
47 | return {'res': x}
48 |
--------------------------------------------------------------------------------
/ppocr/modeling/heads/det_pse_head.py:
--------------------------------------------------------------------------------
1 | # copyright (c) 2021 PaddlePaddle Authors. All Rights Reserve.
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 | """
15 | This code is refer from:
16 | https://github.com/whai362/PSENet/blob/python3/models/head/psenet_head.py
17 | """
18 |
19 | from paddle import nn
20 |
21 |
22 | class PSEHead(nn.Layer):
23 | def __init__(self, in_channels, hidden_dim=256, out_channels=7, **kwargs):
24 | super(PSEHead, self).__init__()
25 | self.conv1 = nn.Conv2D(
26 | in_channels, hidden_dim, kernel_size=3, stride=1, padding=1)
27 | self.bn1 = nn.BatchNorm2D(hidden_dim)
28 | self.relu1 = nn.ReLU()
29 |
30 | self.conv2 = nn.Conv2D(
31 | hidden_dim, out_channels, kernel_size=1, stride=1, padding=0)
32 |
33 | def forward(self, x, **kwargs):
34 | out = self.conv1(x)
35 | out = self.relu1(self.bn1(out))
36 | out = self.conv2(out)
37 | return {'maps': out}
38 |
--------------------------------------------------------------------------------
/ppocr/modeling/heads/rec_pren_head.py:
--------------------------------------------------------------------------------
1 | # copyright (c) 2022 PaddlePaddle Authors. All Rights Reserve.
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | from __future__ import absolute_import
16 | from __future__ import division
17 | from __future__ import print_function
18 |
19 | from paddle import nn
20 | from paddle.nn import functional as F
21 |
22 |
23 | class PRENHead(nn.Layer):
24 | def __init__(self, in_channels, out_channels, **kwargs):
25 | super(PRENHead, self).__init__()
26 | self.linear = nn.Linear(in_channels, out_channels)
27 |
28 | def forward(self, x, targets=None):
29 | predicts = self.linear(x)
30 |
31 | if not self.training:
32 | predicts = F.softmax(predicts, axis=2)
33 |
34 | return predicts
35 |
--------------------------------------------------------------------------------
/ppocr/modeling/necks/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved.
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | __all__ = ['build_neck']
16 |
17 |
18 | def build_neck(config):
19 | from .db_fpn import DBFPN, RSEFPN, LKPAN
20 | from .east_fpn import EASTFPN
21 | from .sast_fpn import SASTFPN
22 | from .rnn import SequenceEncoder
23 | from .pg_fpn import PGFPN
24 | from .table_fpn import TableFPN
25 | from .fpn import FPN
26 | from .fce_fpn import FCEFPN
27 | from .pren_fpn import PRENFPN
28 | from .csp_pan import CSPPAN
29 | from .ct_fpn import CTFPN
30 | from .fpn_unet import FPN_UNet
31 | from .rf_adaptor import RFAdaptor
32 | support_dict = [
33 | 'FPN', 'FCEFPN', 'LKPAN', 'DBFPN', 'RSEFPN', 'EASTFPN', 'SASTFPN',
34 | 'SequenceEncoder', 'PGFPN', 'TableFPN', 'PRENFPN', 'CSPPAN', 'CTFPN',
35 | 'RFAdaptor', 'FPN_UNet'
36 | ]
37 |
38 | module_name = config.pop('name')
39 | assert module_name in support_dict, Exception('neck only support {}'.format(
40 | support_dict))
41 |
42 | module_class = eval(module_name)(**config)
43 | return module_class
44 |
--------------------------------------------------------------------------------
/ppocr/modeling/transforms/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved.
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | __all__ = ['build_transform']
16 |
17 |
18 | def build_transform(config):
19 | from .tps import TPS
20 | from .stn import STN_ON
21 | from .tsrn import TSRN
22 | from .tbsrn import TBSRN
23 | from .gaspin_transformer import GA_SPIN_Transformer as GA_SPIN
24 |
25 | support_dict = ['TPS', 'STN_ON', 'GA_SPIN', 'TSRN', 'TBSRN']
26 |
27 | module_name = config.pop('name')
28 | assert module_name in support_dict, Exception(
29 | 'transform only support {}'.format(support_dict))
30 | module_class = eval(module_name)(**config)
31 | return module_class
32 |
--------------------------------------------------------------------------------
/ppocr/optimizer/regularizer.py:
--------------------------------------------------------------------------------
1 | # copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve.
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | from __future__ import absolute_import
16 | from __future__ import division
17 | from __future__ import print_function
18 | from __future__ import unicode_literals
19 |
20 | import paddle
21 |
22 |
23 | class L1Decay(object):
24 | """
25 | L1 Weight Decay Regularization, which encourages the weights to be sparse.
26 | Args:
27 | factor(float): regularization coeff. Default:0.0.
28 | """
29 |
30 | def __init__(self, factor=0.0):
31 | super(L1Decay, self).__init__()
32 | self.coeff = factor
33 |
34 | def __call__(self):
35 | reg = paddle.regularizer.L1Decay(self.coeff)
36 | return reg
37 |
38 |
39 | class L2Decay(object):
40 | """
41 | L2 Weight Decay Regularization, which helps to prevent the model over-fitting.
42 | Args:
43 | factor(float): regularization coeff. Default:0.0.
44 | """
45 |
46 | def __init__(self, factor=0.0):
47 | super(L2Decay, self).__init__()
48 | self.coeff = float(factor)
49 |
50 | def __call__(self):
51 | return self.coeff
--------------------------------------------------------------------------------
/ppocr/postprocess/cls_postprocess.py:
--------------------------------------------------------------------------------
1 | # copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve.
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 | import paddle
15 |
16 |
17 | class ClsPostProcess(object):
18 | """ Convert between text-label and text-index """
19 |
20 | def __init__(self, label_list=None, key=None, **kwargs):
21 | super(ClsPostProcess, self).__init__()
22 | self.label_list = label_list
23 | self.key = key
24 |
25 | def __call__(self, preds, label=None, *args, **kwargs):
26 | if self.key is not None:
27 | preds = preds[self.key]
28 |
29 | label_list = self.label_list
30 | if label_list is None:
31 | label_list = {idx: idx for idx in range(preds.shape[-1])}
32 |
33 | if isinstance(preds, paddle.Tensor):
34 | preds = preds.numpy()
35 |
36 | pred_idxs = preds.argmax(axis=1)
37 | decode_out = [(label_list[idx], preds[i, idx])
38 | for i, idx in enumerate(pred_idxs)]
39 | if label is None:
40 | return decode_out
41 | label = [(label_list[idx], 1.0) for idx in label]
42 | return decode_out, label
43 |
--------------------------------------------------------------------------------
/ppocr/postprocess/pse_postprocess/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved.
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | from .pse_postprocess import PSEPostProcess
--------------------------------------------------------------------------------
/ppocr/postprocess/pse_postprocess/pse/README.md:
--------------------------------------------------------------------------------
1 | ## 编译
2 | This code is refer from:
3 | https://github.com/whai362/PSENet/blob/python3/models/post_processing/pse
4 | ```python
5 | python3 setup.py build_ext --inplace
6 | ```
7 |
--------------------------------------------------------------------------------
/ppocr/postprocess/pse_postprocess/pse/__init__.py:
--------------------------------------------------------------------------------
1 | # copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve.
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 | import sys
15 | import os
16 | import subprocess
17 |
18 | python_path = sys.executable
19 |
20 | ori_path = os.getcwd()
21 | os.chdir('ppocr/postprocess/pse_postprocess/pse')
22 | if subprocess.call(
23 | '{} setup.py build_ext --inplace'.format(python_path), shell=True) != 0:
24 | raise RuntimeError(
25 | 'Cannot compile pse: {}, if your system is windows, you need to install all the default components of `desktop development using C++` in visual studio 2019+'.
26 | format(os.path.dirname(os.path.realpath(__file__))))
27 | os.chdir(ori_path)
28 |
29 | from .pse import pse
30 |
--------------------------------------------------------------------------------
/ppocr/postprocess/pse_postprocess/pse/setup.py:
--------------------------------------------------------------------------------
1 | from distutils.core import setup, Extension
2 | from Cython.Build import cythonize
3 | import numpy
4 |
5 | setup(ext_modules=cythonize(Extension(
6 | 'pse',
7 | sources=['pse.pyx'],
8 | language='c++',
9 | include_dirs=[numpy.get_include()],
10 | library_dirs=[],
11 | libraries=[],
12 | extra_compile_args=['-O3'],
13 | extra_link_args=[]
14 | )))
15 |
--------------------------------------------------------------------------------
/ppocr/utils/EN_symbol_dict.txt:
--------------------------------------------------------------------------------
1 | 0
2 | 1
3 | 2
4 | 3
5 | 4
6 | 5
7 | 6
8 | 7
9 | 8
10 | 9
11 | a
12 | b
13 | c
14 | d
15 | e
16 | f
17 | g
18 | h
19 | i
20 | j
21 | k
22 | l
23 | m
24 | n
25 | o
26 | p
27 | q
28 | r
29 | s
30 | t
31 | u
32 | v
33 | w
34 | x
35 | y
36 | z
37 | A
38 | B
39 | C
40 | D
41 | E
42 | F
43 | G
44 | H
45 | I
46 | J
47 | K
48 | L
49 | M
50 | N
51 | O
52 | P
53 | Q
54 | R
55 | S
56 | T
57 | U
58 | V
59 | W
60 | X
61 | Y
62 | Z
63 | !
64 | "
65 | #
66 | $
67 | %
68 | &
69 | '
70 | (
71 | )
72 | *
73 | +
74 | ,
75 | -
76 | .
77 | /
78 | :
79 | ;
80 | <
81 | =
82 | >
83 | ?
84 | @
85 | [
86 | \
87 | ]
88 | ^
89 | _
90 | `
91 | {
92 | |
93 | }
94 | ~
--------------------------------------------------------------------------------
/ppocr/utils/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved.
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
--------------------------------------------------------------------------------
/ppocr/utils/dict/ar_dict.txt:
--------------------------------------------------------------------------------
1 | a
2 | r
3 | b
4 | i
5 | c
6 | _
7 | m
8 | g
9 | /
10 | 1
11 | 0
12 | I
13 | L
14 | S
15 | V
16 | R
17 | C
18 | 2
19 | v
20 | l
21 | 6
22 | 3
23 | 9
24 | .
25 | j
26 | p
27 | ا
28 | ل
29 | م
30 | ر
31 | ج
32 | و
33 | ح
34 | ي
35 | ة
36 | 5
37 | 8
38 | 7
39 | أ
40 | ب
41 | ض
42 | 4
43 | ك
44 | س
45 | ه
46 | ث
47 | ن
48 | ط
49 | ع
50 | ت
51 | غ
52 | خ
53 | ف
54 | ئ
55 | ز
56 | إ
57 | د
58 | ص
59 | ظ
60 | ذ
61 | ش
62 | ى
63 | ق
64 | ؤ
65 | آ
66 | ء
67 | s
68 | e
69 | n
70 | w
71 | t
72 | u
73 | z
74 | d
75 | A
76 | N
77 | G
78 | h
79 | o
80 | E
81 | T
82 | H
83 | O
84 | B
85 | y
86 | F
87 | U
88 | J
89 | X
90 | W
91 | P
92 | Z
93 | M
94 | k
95 | q
96 | Y
97 | Q
98 | D
99 | f
100 | K
101 | x
102 | '
103 | %
104 | -
105 | #
106 | @
107 | !
108 | &
109 | $
110 | ,
111 | :
112 | é
113 | ?
114 | +
115 | É
116 | (
117 |
118 |
--------------------------------------------------------------------------------
/ppocr/utils/dict/arabic_dict.txt:
--------------------------------------------------------------------------------
1 | !
2 | #
3 | $
4 | %
5 | &
6 | '
7 | (
8 | +
9 | ,
10 | -
11 | .
12 | /
13 | 0
14 | 1
15 | 2
16 | 3
17 | 4
18 | 5
19 | 6
20 | 7
21 | 8
22 | 9
23 | :
24 | ?
25 | @
26 | A
27 | B
28 | C
29 | D
30 | E
31 | F
32 | G
33 | H
34 | I
35 | J
36 | K
37 | L
38 | M
39 | N
40 | O
41 | P
42 | Q
43 | R
44 | S
45 | T
46 | U
47 | V
48 | W
49 | X
50 | Y
51 | Z
52 | _
53 | a
54 | b
55 | c
56 | d
57 | e
58 | f
59 | g
60 | h
61 | i
62 | j
63 | k
64 | l
65 | m
66 | n
67 | o
68 | p
69 | q
70 | r
71 | s
72 | t
73 | u
74 | v
75 | w
76 | x
77 | y
78 | z
79 | É
80 | é
81 | ء
82 | آ
83 | أ
84 | ؤ
85 | إ
86 | ئ
87 | ا
88 | ب
89 | ة
90 | ت
91 | ث
92 | ج
93 | ح
94 | خ
95 | د
96 | ذ
97 | ر
98 | ز
99 | س
100 | ش
101 | ص
102 | ض
103 | ط
104 | ظ
105 | ع
106 | غ
107 | ف
108 | ق
109 | ك
110 | ل
111 | م
112 | ن
113 | ه
114 | و
115 | ى
116 | ي
117 | ً
118 | ٌ
119 | ٍ
120 | َ
121 | ُ
122 | ِ
123 | ّ
124 | ْ
125 | ٓ
126 | ٔ
127 | ٰ
128 | ٱ
129 | ٹ
130 | پ
131 | چ
132 | ڈ
133 | ڑ
134 | ژ
135 | ک
136 | ڭ
137 | گ
138 | ں
139 | ھ
140 | ۀ
141 | ہ
142 | ۂ
143 | ۃ
144 | ۆ
145 | ۇ
146 | ۈ
147 | ۋ
148 | ی
149 | ې
150 | ے
151 | ۓ
152 | ە
153 | ١
154 | ٢
155 | ٣
156 | ٤
157 | ٥
158 | ٦
159 | ٧
160 | ٨
161 | ٩
162 |
--------------------------------------------------------------------------------
/ppocr/utils/dict/be_dict.txt:
--------------------------------------------------------------------------------
1 | b
2 | e
3 | _
4 | i
5 | m
6 | g
7 | /
8 | 2
9 | 0
10 | I
11 | L
12 | S
13 | V
14 | R
15 | C
16 | 1
17 | v
18 | a
19 | l
20 | 6
21 | 9
22 | 4
23 | 3
24 | .
25 | j
26 | p
27 | п
28 | а
29 | з
30 | б
31 | у
32 | г
33 | н
34 | ц
35 | ь
36 | 8
37 | м
38 | л
39 | і
40 | о
41 | ў
42 | ы
43 | 7
44 | 5
45 | М
46 | х
47 | с
48 | р
49 | ф
50 | я
51 | е
52 | д
53 | ж
54 | ю
55 | ч
56 | й
57 | к
58 | Д
59 | в
60 | Б
61 | т
62 | І
63 | ш
64 | ё
65 | э
66 | К
67 | Л
68 | Н
69 | А
70 | Ж
71 | Г
72 | В
73 | П
74 | З
75 | Е
76 | О
77 | Р
78 | С
79 | У
80 | Ё
81 | Й
82 | Т
83 | Ч
84 | Э
85 | Ц
86 | Ю
87 | Ш
88 | Ф
89 | Х
90 | Я
91 | Ь
92 | Ы
93 | Ў
94 | s
95 | c
96 | n
97 | w
98 | M
99 | o
100 | t
101 | T
102 | E
103 | A
104 | B
105 | u
106 | h
107 | y
108 | k
109 | r
110 | H
111 | d
112 | Y
113 | O
114 | U
115 | F
116 | f
117 | x
118 | D
119 | G
120 | N
121 | K
122 | P
123 | z
124 | J
125 | X
126 | W
127 | Z
128 | Q
129 | %
130 | -
131 | q
132 | @
133 | '
134 | !
135 | #
136 | &
137 | ,
138 | :
139 | $
140 | (
141 | ?
142 | é
143 | +
144 | É
145 |
146 |
--------------------------------------------------------------------------------
/ppocr/utils/dict/bg_dict.txt:
--------------------------------------------------------------------------------
1 | !
2 | #
3 | $
4 | %
5 | &
6 | '
7 | (
8 | +
9 | ,
10 | -
11 | .
12 | /
13 | 0
14 | 1
15 | 2
16 | 3
17 | 4
18 | 5
19 | 6
20 | 7
21 | 8
22 | 9
23 | :
24 | ?
25 | @
26 | A
27 | B
28 | C
29 | D
30 | E
31 | F
32 | G
33 | H
34 | I
35 | J
36 | K
37 | L
38 | M
39 | N
40 | O
41 | P
42 | Q
43 | R
44 | S
45 | T
46 | U
47 | V
48 | W
49 | X
50 | Y
51 | Z
52 | _
53 | a
54 | b
55 | c
56 | d
57 | e
58 | f
59 | g
60 | h
61 | i
62 | j
63 | k
64 | l
65 | m
66 | n
67 | o
68 | p
69 | q
70 | r
71 | s
72 | t
73 | u
74 | v
75 | w
76 | x
77 | y
78 | z
79 | É
80 | é
81 | А
82 | Б
83 | В
84 | Г
85 | Д
86 | Е
87 | Ж
88 | З
89 | И
90 | Й
91 | К
92 | Л
93 | М
94 | Н
95 | О
96 | П
97 | Р
98 | С
99 | Т
100 | У
101 | Ф
102 | Х
103 | Ц
104 | Ч
105 | Ш
106 | Щ
107 | Ъ
108 | Ю
109 | Я
110 | а
111 | б
112 | в
113 | г
114 | д
115 | е
116 | ж
117 | з
118 | и
119 | й
120 | к
121 | л
122 | м
123 | н
124 | о
125 | п
126 | р
127 | с
128 | т
129 | у
130 | ф
131 | х
132 | ц
133 | ч
134 | ш
135 | щ
136 | ъ
137 | ь
138 | ю
139 | я
140 |
141 |
--------------------------------------------------------------------------------
/ppocr/utils/dict/confuse.pkl:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WenmuZhou/PytorchOCR/f899e9ddf953cbbcfb3f269318d0daa5ebcd2b53/ppocr/utils/dict/confuse.pkl
--------------------------------------------------------------------------------
/ppocr/utils/dict/cyrillic_dict.txt:
--------------------------------------------------------------------------------
1 |
2 | !
3 | #
4 | $
5 | %
6 | &
7 | '
8 | (
9 | +
10 | ,
11 | -
12 | .
13 | /
14 | 0
15 | 1
16 | 2
17 | 3
18 | 4
19 | 5
20 | 6
21 | 7
22 | 8
23 | 9
24 | :
25 | ?
26 | @
27 | A
28 | B
29 | C
30 | D
31 | E
32 | F
33 | G
34 | H
35 | I
36 | J
37 | K
38 | L
39 | M
40 | N
41 | O
42 | P
43 | Q
44 | R
45 | S
46 | T
47 | U
48 | V
49 | W
50 | X
51 | Y
52 | Z
53 | _
54 | a
55 | b
56 | c
57 | d
58 | e
59 | f
60 | g
61 | h
62 | i
63 | j
64 | k
65 | l
66 | m
67 | n
68 | o
69 | p
70 | q
71 | r
72 | s
73 | t
74 | u
75 | v
76 | w
77 | x
78 | y
79 | z
80 | É
81 | é
82 | Ё
83 | Є
84 | І
85 | Ј
86 | Љ
87 | Ў
88 | А
89 | Б
90 | В
91 | Г
92 | Д
93 | Е
94 | Ж
95 | З
96 | И
97 | Й
98 | К
99 | Л
100 | М
101 | Н
102 | О
103 | П
104 | Р
105 | С
106 | Т
107 | У
108 | Ф
109 | Х
110 | Ц
111 | Ч
112 | Ш
113 | Щ
114 | Ъ
115 | Ы
116 | Ь
117 | Э
118 | Ю
119 | Я
120 | а
121 | б
122 | в
123 | г
124 | д
125 | е
126 | ж
127 | з
128 | и
129 | й
130 | к
131 | л
132 | м
133 | н
134 | о
135 | п
136 | р
137 | с
138 | т
139 | у
140 | ф
141 | х
142 | ц
143 | ч
144 | ш
145 | щ
146 | ъ
147 | ы
148 | ь
149 | э
150 | ю
151 | я
152 | ё
153 | ђ
154 | є
155 | і
156 | ј
157 | љ
158 | њ
159 | ћ
160 | ў
161 | џ
162 | Ґ
163 | ґ
164 |
--------------------------------------------------------------------------------
/ppocr/utils/dict/devanagari_dict.txt:
--------------------------------------------------------------------------------
1 |
2 | !
3 | #
4 | $
5 | %
6 | &
7 | '
8 | (
9 | +
10 | ,
11 | -
12 | .
13 | /
14 | 0
15 | 1
16 | 2
17 | 3
18 | 4
19 | 5
20 | 6
21 | 7
22 | 8
23 | 9
24 | :
25 | ?
26 | @
27 | A
28 | B
29 | C
30 | D
31 | E
32 | F
33 | G
34 | H
35 | I
36 | J
37 | K
38 | L
39 | M
40 | N
41 | O
42 | P
43 | Q
44 | R
45 | S
46 | T
47 | U
48 | V
49 | W
50 | X
51 | Y
52 | Z
53 | _
54 | a
55 | b
56 | c
57 | d
58 | e
59 | f
60 | g
61 | h
62 | i
63 | j
64 | k
65 | l
66 | m
67 | n
68 | o
69 | p
70 | q
71 | r
72 | s
73 | t
74 | u
75 | v
76 | w
77 | x
78 | y
79 | z
80 | É
81 | é
82 | ँ
83 | ं
84 | ः
85 | अ
86 | आ
87 | इ
88 | ई
89 | उ
90 | ऊ
91 | ऋ
92 | ए
93 | ऐ
94 | ऑ
95 | ओ
96 | औ
97 | क
98 | ख
99 | ग
100 | घ
101 | ङ
102 | च
103 | छ
104 | ज
105 | झ
106 | ञ
107 | ट
108 | ठ
109 | ड
110 | ढ
111 | ण
112 | त
113 | थ
114 | द
115 | ध
116 | न
117 | ऩ
118 | प
119 | फ
120 | ब
121 | भ
122 | म
123 | य
124 | र
125 | ऱ
126 | ल
127 | ळ
128 | व
129 | श
130 | ष
131 | स
132 | ह
133 | ़
134 | ा
135 | ि
136 | ी
137 | ु
138 | ू
139 | ृ
140 | ॅ
141 | े
142 | ै
143 | ॉ
144 | ो
145 | ौ
146 | ्
147 | ॒
148 | क़
149 | ख़
150 | ग़
151 | ज़
152 | ड़
153 | ढ़
154 | फ़
155 | ॠ
156 | ।
157 | ०
158 | १
159 | २
160 | ३
161 | ४
162 | ५
163 | ६
164 | ७
165 | ८
166 | ९
167 | ॰
168 |
--------------------------------------------------------------------------------
/ppocr/utils/dict/en_dict.txt:
--------------------------------------------------------------------------------
1 | 0
2 | 1
3 | 2
4 | 3
5 | 4
6 | 5
7 | 6
8 | 7
9 | 8
10 | 9
11 | a
12 | b
13 | c
14 | d
15 | e
16 | f
17 | g
18 | h
19 | i
20 | j
21 | k
22 | l
23 | m
24 | n
25 | o
26 | p
27 | q
28 | r
29 | s
30 | t
31 | u
32 | v
33 | w
34 | x
35 | y
36 | z
37 | A
38 | B
39 | C
40 | D
41 | E
42 | F
43 | G
44 | H
45 | I
46 | J
47 | K
48 | L
49 | M
50 | N
51 | O
52 | P
53 | Q
54 | R
55 | S
56 | T
57 | U
58 | V
59 | W
60 | X
61 | Y
62 | Z
63 |
64 |
--------------------------------------------------------------------------------
/ppocr/utils/dict/fa_dict.txt:
--------------------------------------------------------------------------------
1 | f
2 | a
3 | _
4 | i
5 | m
6 | g
7 | /
8 | 1
9 | 3
10 | I
11 | L
12 | S
13 | V
14 | R
15 | C
16 | 2
17 | 0
18 | v
19 | l
20 | 6
21 | 8
22 | 5
23 | .
24 | j
25 | p
26 | و
27 | د
28 | ر
29 | ك
30 | ن
31 | ش
32 | ه
33 | ا
34 | 4
35 | 9
36 | ی
37 | ج
38 | ِ
39 | 7
40 | غ
41 | ل
42 | س
43 | ز
44 | ّ
45 | ت
46 | ک
47 | گ
48 | ي
49 | م
50 | ب
51 | ف
52 | چ
53 | خ
54 | ق
55 | ژ
56 | آ
57 | ص
58 | پ
59 | َ
60 | ع
61 | ئ
62 | ح
63 | ٔ
64 | ض
65 | ُ
66 | ذ
67 | أ
68 | ى
69 | ط
70 | ظ
71 | ث
72 | ة
73 | ً
74 | ء
75 | ؤ
76 | ْ
77 | ۀ
78 | إ
79 | ٍ
80 | ٌ
81 | ٰ
82 | ٓ
83 | ٱ
84 | s
85 | c
86 | e
87 | n
88 | w
89 | N
90 | E
91 | W
92 | Y
93 | D
94 | O
95 | H
96 | A
97 | d
98 | z
99 | r
100 | T
101 | G
102 | o
103 | t
104 | x
105 | h
106 | b
107 | B
108 | M
109 | Z
110 | u
111 | P
112 | F
113 | y
114 | q
115 | U
116 | K
117 | k
118 | J
119 | Q
120 | '
121 | X
122 | #
123 | ?
124 | %
125 | $
126 | ,
127 | :
128 | &
129 | !
130 | -
131 | (
132 | É
133 | @
134 | é
135 | +
136 |
137 |
--------------------------------------------------------------------------------
/ppocr/utils/dict/french_dict.txt:
--------------------------------------------------------------------------------
1 | f
2 | e
3 | n
4 | c
5 | h
6 | _
7 | i
8 | m
9 | g
10 | /
11 | r
12 | v
13 | a
14 | l
15 | t
16 | w
17 | o
18 | d
19 | 6
20 | 1
21 | .
22 | p
23 | B
24 | u
25 | 2
26 | à
27 | 3
28 | R
29 | y
30 | 4
31 | U
32 | E
33 | A
34 | 5
35 | P
36 | O
37 | S
38 | T
39 | D
40 | 7
41 | Z
42 | 8
43 | I
44 | N
45 | L
46 | G
47 | M
48 | H
49 | 0
50 | J
51 | K
52 | -
53 | 9
54 | F
55 | C
56 | V
57 | é
58 | X
59 | '
60 | s
61 | Q
62 | :
63 | è
64 | x
65 | b
66 | Y
67 | Œ
68 | É
69 | z
70 | W
71 | Ç
72 | È
73 | k
74 | Ô
75 | ô
76 | €
77 | À
78 | Ê
79 | q
80 | ù
81 | °
82 | ê
83 | î
84 | *
85 | Â
86 | j
87 | "
88 | ,
89 | â
90 | %
91 | û
92 | ç
93 | ü
94 | ?
95 | !
96 | ;
97 | ö
98 | (
99 | )
100 | ï
101 | º
102 | ó
103 | ø
104 | å
105 | +
106 | ™
107 | á
108 | Ë
109 | <
110 | ²
111 | Á
112 | Î
113 | &
114 | @
115 | œ
116 | ε
117 | Ü
118 | ë
119 | [
120 | ]
121 | í
122 | ò
123 | Ö
124 | ä
125 | ß
126 | «
127 | »
128 | ú
129 | ñ
130 | æ
131 | µ
132 | ³
133 | Å
134 | $
135 | #
136 |
137 |
--------------------------------------------------------------------------------
/ppocr/utils/dict/german_dict.txt:
--------------------------------------------------------------------------------
1 |
2 | !
3 | "
4 | #
5 | $
6 | %
7 | &
8 | '
9 | (
10 | )
11 | *
12 | +
13 | ,
14 | -
15 | .
16 | /
17 | 0
18 | 1
19 | 2
20 | 3
21 | 4
22 | 5
23 | 6
24 | 7
25 | 8
26 | 9
27 | :
28 | ;
29 | =
30 | >
31 | ?
32 | @
33 | A
34 | B
35 | C
36 | D
37 | E
38 | F
39 | G
40 | H
41 | I
42 | J
43 | K
44 | L
45 | M
46 | N
47 | O
48 | P
49 | Q
50 | R
51 | S
52 | T
53 | U
54 | V
55 | W
56 | X
57 | Y
58 | Z
59 | [
60 | ]
61 | _
62 | a
63 | b
64 | c
65 | d
66 | e
67 | f
68 | g
69 | h
70 | i
71 | j
72 | k
73 | l
74 | m
75 | n
76 | o
77 | p
78 | q
79 | r
80 | s
81 | t
82 | u
83 | v
84 | w
85 | x
86 | y
87 | z
88 | £
89 | §
90 |
91 | °
92 | ´
93 | µ
94 | ·
95 | º
96 | ¿
97 | Á
98 | Ä
99 | Å
100 | É
101 | Ï
102 | Ô
103 | Ö
104 | Ü
105 | ß
106 | à
107 | á
108 | â
109 | ã
110 | ä
111 | å
112 | æ
113 | ç
114 | è
115 | é
116 | ê
117 | ë
118 | í
119 | ï
120 | ñ
121 | ò
122 | ó
123 | ô
124 | ö
125 | ø
126 | ù
127 | ú
128 | û
129 | ü
130 | ō
131 | Š
132 | Ÿ
133 | ʒ
134 | β
135 | δ
136 | з
137 | Ṡ
138 | ‘
139 | €
140 | ©
141 | ª
142 | «
143 | ¬
144 |
--------------------------------------------------------------------------------
/ppocr/utils/dict/hi_dict.txt:
--------------------------------------------------------------------------------
1 |
2 | !
3 | #
4 | $
5 | %
6 | &
7 | '
8 | (
9 | +
10 | ,
11 | -
12 | .
13 | /
14 | 0
15 | 1
16 | 2
17 | 3
18 | 4
19 | 5
20 | 6
21 | 7
22 | 8
23 | 9
24 | :
25 | ?
26 | @
27 | A
28 | B
29 | C
30 | D
31 | E
32 | F
33 | G
34 | H
35 | I
36 | J
37 | K
38 | L
39 | M
40 | N
41 | O
42 | P
43 | Q
44 | R
45 | S
46 | T
47 | U
48 | V
49 | W
50 | X
51 | Y
52 | Z
53 | _
54 | a
55 | b
56 | c
57 | d
58 | e
59 | f
60 | g
61 | h
62 | i
63 | j
64 | k
65 | l
66 | m
67 | n
68 | o
69 | p
70 | q
71 | r
72 | s
73 | t
74 | u
75 | v
76 | w
77 | x
78 | y
79 | z
80 | É
81 | é
82 | ँ
83 | ं
84 | ः
85 | अ
86 | आ
87 | इ
88 | ई
89 | उ
90 | ऊ
91 | ऋ
92 | ए
93 | ऐ
94 | ऑ
95 | ओ
96 | औ
97 | क
98 | ख
99 | ग
100 | घ
101 | ङ
102 | च
103 | छ
104 | ज
105 | झ
106 | ञ
107 | ट
108 | ठ
109 | ड
110 | ढ
111 | ण
112 | त
113 | थ
114 | द
115 | ध
116 | न
117 | प
118 | फ
119 | ब
120 | भ
121 | म
122 | य
123 | र
124 | ल
125 | ळ
126 | व
127 | श
128 | ष
129 | स
130 | ह
131 | ़
132 | ा
133 | ि
134 | ी
135 | ु
136 | ू
137 | ृ
138 | ॅ
139 | े
140 | ै
141 | ॉ
142 | ो
143 | ौ
144 | ्
145 | क़
146 | ख़
147 | ग़
148 | ज़
149 | ड़
150 | ढ़
151 | फ़
152 | ०
153 | १
154 | २
155 | ३
156 | ४
157 | ५
158 | ६
159 | ७
160 | ८
161 | ९
162 | ॰
163 |
--------------------------------------------------------------------------------
/ppocr/utils/dict/it_dict.txt:
--------------------------------------------------------------------------------
1 | i
2 | t
3 | _
4 | m
5 | g
6 | /
7 | 5
8 | I
9 | L
10 | S
11 | V
12 | R
13 | C
14 | 2
15 | 0
16 | 1
17 | v
18 | a
19 | l
20 | 7
21 | 8
22 | 9
23 | 6
24 | .
25 | j
26 | p
27 |
28 | e
29 | r
30 | o
31 | d
32 | s
33 | n
34 | 3
35 | 4
36 | P
37 | u
38 | c
39 | A
40 | -
41 | ,
42 | "
43 | z
44 | h
45 | f
46 | b
47 | q
48 | ì
49 | '
50 | à
51 | O
52 | è
53 | G
54 | ù
55 | é
56 | ò
57 | ;
58 | F
59 | E
60 | B
61 | N
62 | H
63 | k
64 | :
65 | U
66 | T
67 | X
68 | D
69 | K
70 | ?
71 | [
72 | M
73 |
74 | x
75 | y
76 | (
77 | )
78 | W
79 | ö
80 | º
81 | w
82 | ]
83 | Q
84 | J
85 | +
86 | ü
87 | !
88 | È
89 | á
90 | %
91 | =
92 | »
93 | ñ
94 | Ö
95 | Y
96 | ä
97 | í
98 | Z
99 | «
100 | @
101 | ó
102 | ø
103 | ï
104 | ú
105 | ê
106 | ç
107 | Á
108 | É
109 | Å
110 | ß
111 | {
112 | }
113 | &
114 | `
115 | û
116 | î
117 | #
118 | $
119 |
--------------------------------------------------------------------------------
/ppocr/utils/dict/ka_dict.txt:
--------------------------------------------------------------------------------
1 | k
2 | a
3 | _
4 | i
5 | m
6 | g
7 | /
8 | 1
9 | 2
10 | I
11 | L
12 | S
13 | V
14 | R
15 | C
16 | 0
17 | v
18 | l
19 | 6
20 | 4
21 | 8
22 | .
23 | j
24 | p
25 | ಗ
26 | ು
27 | ಣ
28 | ಪ
29 | ಡ
30 | ಿ
31 | ಸ
32 | ಲ
33 | ಾ
34 | ದ
35 | ್
36 | 7
37 | 5
38 | 3
39 | ವ
40 | ಷ
41 | ಬ
42 | ಹ
43 | ೆ
44 | 9
45 | ಅ
46 | ಳ
47 | ನ
48 | ರ
49 | ಉ
50 | ಕ
51 | ಎ
52 | ೇ
53 | ಂ
54 | ೈ
55 | ೊ
56 | ೀ
57 | ಯ
58 | ೋ
59 | ತ
60 | ಶ
61 | ಭ
62 | ಧ
63 | ಚ
64 | ಜ
65 | ೂ
66 | ಮ
67 | ಒ
68 | ೃ
69 | ಥ
70 | ಇ
71 | ಟ
72 | ಖ
73 | ಆ
74 | ಞ
75 | ಫ
76 | -
77 | ಢ
78 | ಊ
79 | ಓ
80 | ಐ
81 | ಃ
82 | ಘ
83 | ಝ
84 | ೌ
85 | ಠ
86 | ಛ
87 | ಔ
88 | ಏ
89 | ಈ
90 | ಋ
91 | ೨
92 | ೦
93 | ೧
94 | ೮
95 | ೯
96 | ೪
97 | ,
98 | ೫
99 | ೭
100 | ೩
101 | ೬
102 | ಙ
103 | s
104 | c
105 | e
106 | n
107 | w
108 | o
109 | u
110 | t
111 | d
112 | E
113 | A
114 | T
115 | B
116 | Z
117 | N
118 | G
119 | O
120 | q
121 | z
122 | r
123 | x
124 | P
125 | K
126 | M
127 | J
128 | U
129 | D
130 | f
131 | F
132 | h
133 | b
134 | W
135 | Y
136 | y
137 | H
138 | X
139 | Q
140 | '
141 | #
142 | &
143 | !
144 | @
145 | $
146 | :
147 | %
148 | é
149 | É
150 | (
151 | ?
152 | +
153 |
154 |
--------------------------------------------------------------------------------
/ppocr/utils/dict/kie_dict/xfund_class_list.txt:
--------------------------------------------------------------------------------
1 | OTHER
2 | QUESTION
3 | ANSWER
4 | HEADER
5 |
--------------------------------------------------------------------------------
/ppocr/utils/dict/latex_symbol_dict.txt:
--------------------------------------------------------------------------------
1 | eos
2 | sos
3 | !
4 | '
5 | (
6 | )
7 | +
8 | ,
9 | -
10 | .
11 | /
12 | 0
13 | 1
14 | 2
15 | 3
16 | 4
17 | 5
18 | 6
19 | 7
20 | 8
21 | 9
22 | <
23 | =
24 | >
25 | A
26 | B
27 | C
28 | E
29 | F
30 | G
31 | H
32 | I
33 | L
34 | M
35 | N
36 | P
37 | R
38 | S
39 | T
40 | V
41 | X
42 | Y
43 | [
44 | \Delta
45 | \alpha
46 | \beta
47 | \cdot
48 | \cdots
49 | \cos
50 | \div
51 | \exists
52 | \forall
53 | \frac
54 | \gamma
55 | \geq
56 | \in
57 | \infty
58 | \int
59 | \lambda
60 | \ldots
61 | \leq
62 | \lim
63 | \log
64 | \mu
65 | \neq
66 | \phi
67 | \pi
68 | \pm
69 | \prime
70 | \rightarrow
71 | \sigma
72 | \sin
73 | \sqrt
74 | \sum
75 | \tan
76 | \theta
77 | \times
78 | ]
79 | a
80 | b
81 | c
82 | d
83 | e
84 | f
85 | g
86 | h
87 | i
88 | j
89 | k
90 | l
91 | m
92 | n
93 | o
94 | p
95 | q
96 | r
97 | s
98 | t
99 | u
100 | v
101 | w
102 | x
103 | y
104 | z
105 | \{
106 | |
107 | \}
108 | {
109 | }
110 | ^
111 | _
--------------------------------------------------------------------------------
/ppocr/utils/dict/latin_dict.txt:
--------------------------------------------------------------------------------
1 |
2 | !
3 | "
4 | #
5 | $
6 | %
7 | &
8 | '
9 | (
10 | )
11 | *
12 | +
13 | ,
14 | -
15 | .
16 | /
17 | 0
18 | 1
19 | 2
20 | 3
21 | 4
22 | 5
23 | 6
24 | 7
25 | 8
26 | 9
27 | :
28 | ;
29 | <
30 | =
31 | >
32 | ?
33 | @
34 | A
35 | B
36 | C
37 | D
38 | E
39 | F
40 | G
41 | H
42 | I
43 | J
44 | K
45 | L
46 | M
47 | N
48 | O
49 | P
50 | Q
51 | R
52 | S
53 | T
54 | U
55 | V
56 | W
57 | X
58 | Y
59 | Z
60 | [
61 | ]
62 | _
63 | `
64 | a
65 | b
66 | c
67 | d
68 | e
69 | f
70 | g
71 | h
72 | i
73 | j
74 | k
75 | l
76 | m
77 | n
78 | o
79 | p
80 | q
81 | r
82 | s
83 | t
84 | u
85 | v
86 | w
87 | x
88 | y
89 | z
90 | {
91 | }
92 | ¡
93 | £
94 | §
95 | ª
96 | «
97 |
98 | °
99 | ²
100 | ³
101 | ´
102 | µ
103 | ·
104 | º
105 | »
106 | ¿
107 | À
108 | Á
109 | Â
110 | Ä
111 | Å
112 | Ç
113 | È
114 | É
115 | Ê
116 | Ë
117 | Ì
118 | Í
119 | Î
120 | Ï
121 | Ò
122 | Ó
123 | Ô
124 | Õ
125 | Ö
126 | Ú
127 | Ü
128 | Ý
129 | ß
130 | à
131 | á
132 | â
133 | ã
134 | ä
135 | å
136 | æ
137 | ç
138 | è
139 | é
140 | ê
141 | ë
142 | ì
143 | í
144 | î
145 | ï
146 | ñ
147 | ò
148 | ó
149 | ô
150 | õ
151 | ö
152 | ø
153 | ù
154 | ú
155 | û
156 | ü
157 | ý
158 | ą
159 | Ć
160 | ć
161 | Č
162 | č
163 | Đ
164 | đ
165 | ę
166 | ı
167 | Ł
168 | ł
169 | ō
170 | Œ
171 | œ
172 | Š
173 | š
174 | Ÿ
175 | Ž
176 | ž
177 | ʒ
178 | β
179 | δ
180 | ε
181 | з
182 | Ṡ
183 | ‘
184 | €
185 | ™
186 |
--------------------------------------------------------------------------------
/ppocr/utils/dict/layout_dict/layout_cdla_dict.txt:
--------------------------------------------------------------------------------
1 | text
2 | title
3 | figure
4 | figure_caption
5 | table
6 | table_caption
7 | header
8 | footer
9 | reference
10 | equation
--------------------------------------------------------------------------------
/ppocr/utils/dict/layout_dict/layout_publaynet_dict.txt:
--------------------------------------------------------------------------------
1 | text
2 | title
3 | list
4 | table
5 | figure
--------------------------------------------------------------------------------
/ppocr/utils/dict/layout_dict/layout_table_dict.txt:
--------------------------------------------------------------------------------
1 | table
--------------------------------------------------------------------------------
/ppocr/utils/dict/mr_dict.txt:
--------------------------------------------------------------------------------
1 |
2 | !
3 | #
4 | $
5 | %
6 | &
7 | '
8 | (
9 | +
10 | ,
11 | -
12 | .
13 | /
14 | 0
15 | 1
16 | 2
17 | 3
18 | 4
19 | 5
20 | 6
21 | 7
22 | 8
23 | 9
24 | :
25 | ?
26 | @
27 | A
28 | B
29 | C
30 | D
31 | E
32 | F
33 | G
34 | H
35 | I
36 | J
37 | K
38 | L
39 | M
40 | N
41 | O
42 | P
43 | Q
44 | R
45 | S
46 | T
47 | U
48 | V
49 | W
50 | X
51 | Y
52 | Z
53 | _
54 | a
55 | b
56 | c
57 | d
58 | e
59 | f
60 | g
61 | h
62 | i
63 | j
64 | k
65 | l
66 | m
67 | n
68 | o
69 | p
70 | q
71 | r
72 | s
73 | t
74 | u
75 | v
76 | w
77 | x
78 | y
79 | z
80 | É
81 | é
82 | ँ
83 | ं
84 | ः
85 | अ
86 | आ
87 | इ
88 | ई
89 | उ
90 | ऊ
91 | ए
92 | ऐ
93 | ऑ
94 | ओ
95 | औ
96 | क
97 | ख
98 | ग
99 | घ
100 | च
101 | छ
102 | ज
103 | झ
104 | ञ
105 | ट
106 | ठ
107 | ड
108 | ढ
109 | ण
110 | त
111 | थ
112 | द
113 | ध
114 | न
115 | प
116 | फ
117 | ब
118 | भ
119 | म
120 | य
121 | र
122 | ऱ
123 | ल
124 | ळ
125 | व
126 | श
127 | ष
128 | स
129 | ह
130 | ़
131 | ा
132 | ि
133 | ी
134 | ु
135 | ू
136 | ृ
137 | ॅ
138 | े
139 | ै
140 | ॉ
141 | ो
142 | ौ
143 | ्
144 | ०
145 | १
146 | २
147 | ३
148 | ४
149 | ५
150 | ६
151 | ७
152 | ८
153 | ९
154 |
--------------------------------------------------------------------------------
/ppocr/utils/dict/ne_dict.txt:
--------------------------------------------------------------------------------
1 |
2 | !
3 | #
4 | $
5 | %
6 | &
7 | '
8 | (
9 | +
10 | ,
11 | -
12 | .
13 | /
14 | 0
15 | 1
16 | 2
17 | 3
18 | 4
19 | 5
20 | 6
21 | 7
22 | 8
23 | 9
24 | :
25 | ?
26 | @
27 | A
28 | B
29 | C
30 | D
31 | E
32 | F
33 | G
34 | H
35 | I
36 | J
37 | K
38 | L
39 | M
40 | N
41 | O
42 | P
43 | Q
44 | R
45 | S
46 | T
47 | U
48 | V
49 | W
50 | X
51 | Y
52 | Z
53 | _
54 | a
55 | b
56 | c
57 | d
58 | e
59 | f
60 | g
61 | h
62 | i
63 | j
64 | k
65 | l
66 | m
67 | n
68 | o
69 | p
70 | q
71 | r
72 | s
73 | t
74 | u
75 | v
76 | w
77 | x
78 | y
79 | z
80 | É
81 | é
82 | ः
83 | अ
84 | आ
85 | इ
86 | ई
87 | उ
88 | ऊ
89 | ऋ
90 | ए
91 | ऐ
92 | ओ
93 | औ
94 | क
95 | ख
96 | ग
97 | घ
98 | ङ
99 | च
100 | छ
101 | ज
102 | झ
103 | ञ
104 | ट
105 | ठ
106 | ड
107 | ढ
108 | ण
109 | त
110 | थ
111 | द
112 | ध
113 | न
114 | ऩ
115 | प
116 | फ
117 | ब
118 | भ
119 | म
120 | य
121 | र
122 | ऱ
123 | ल
124 | व
125 | श
126 | ष
127 | स
128 | ह
129 | ़
130 | ा
131 | ि
132 | ी
133 | ु
134 | ू
135 | ृ
136 | े
137 | ै
138 | ो
139 | ौ
140 | ्
141 | ॒
142 | ॠ
143 | ।
144 | ०
145 | १
146 | २
147 | ३
148 | ४
149 | ५
150 | ६
151 | ७
152 | ८
153 | ९
154 |
--------------------------------------------------------------------------------
/ppocr/utils/dict/oc_dict.txt:
--------------------------------------------------------------------------------
1 | o
2 | c
3 | _
4 | i
5 | m
6 | g
7 | /
8 | 2
9 | 0
10 | I
11 | L
12 | S
13 | V
14 | R
15 | C
16 | 1
17 | v
18 | a
19 | l
20 | 4
21 | 3
22 | .
23 | j
24 | p
25 | r
26 | e
27 | è
28 | t
29 | 9
30 | 7
31 | 5
32 | 8
33 | n
34 | '
35 | b
36 | s
37 | 6
38 | q
39 | u
40 | á
41 | d
42 | ò
43 | à
44 | h
45 | z
46 | f
47 | ï
48 | í
49 | A
50 | ç
51 | x
52 | ó
53 | é
54 | P
55 | O
56 | Ò
57 | ü
58 | k
59 | À
60 | F
61 | -
62 | ú
63 |
64 | æ
65 | Á
66 | D
67 | E
68 | w
69 | K
70 | T
71 | N
72 | y
73 | U
74 | Z
75 | G
76 | B
77 | J
78 | H
79 | M
80 | W
81 | Y
82 | X
83 | Q
84 | %
85 | $
86 | ,
87 | @
88 | &
89 | !
90 | :
91 | (
92 | #
93 | ?
94 | +
95 | É
96 |
97 |
--------------------------------------------------------------------------------
/ppocr/utils/dict/pu_dict.txt:
--------------------------------------------------------------------------------
1 | p
2 | u
3 | _
4 | i
5 | m
6 | g
7 | /
8 | 8
9 | I
10 | L
11 | S
12 | V
13 | R
14 | C
15 | 2
16 | 0
17 | 1
18 | v
19 | a
20 | l
21 | 6
22 | 7
23 | 4
24 | 5
25 | .
26 | j
27 |
28 | q
29 | e
30 | s
31 | t
32 | ã
33 | o
34 | x
35 | 9
36 | c
37 | n
38 | r
39 | z
40 | ç
41 | õ
42 | 3
43 | A
44 | U
45 | d
46 | º
47 | ô
48 |
49 | ,
50 | E
51 | ;
52 | ó
53 | á
54 | b
55 | D
56 | ?
57 | ú
58 | ê
59 | -
60 | h
61 | P
62 | f
63 | à
64 | N
65 | í
66 | O
67 | M
68 | G
69 | É
70 | é
71 | â
72 | F
73 | :
74 | T
75 | Á
76 | "
77 | Q
78 | )
79 | W
80 | J
81 | B
82 | H
83 | (
84 | ö
85 | %
86 | Ö
87 | «
88 | w
89 | K
90 | y
91 | !
92 | k
93 | ]
94 | '
95 | Z
96 | +
97 | Ç
98 | Õ
99 | Y
100 | À
101 | X
102 | µ
103 | »
104 | ª
105 | Í
106 | ü
107 | ä
108 | ´
109 | è
110 | ñ
111 | ß
112 | ï
113 | Ú
114 | ë
115 | Ô
116 | Ï
117 | Ó
118 | [
119 | Ì
120 | <
121 | Â
122 | ò
123 | §
124 | ³
125 | ø
126 | å
127 | #
128 | $
129 | &
130 | @
131 |
--------------------------------------------------------------------------------
/ppocr/utils/dict/rs_dict.txt:
--------------------------------------------------------------------------------
1 | r
2 | s
3 | _
4 | i
5 | m
6 | g
7 | /
8 | 1
9 | I
10 | L
11 | S
12 | V
13 | R
14 | C
15 | 2
16 | 0
17 | v
18 | a
19 | l
20 | 7
21 | 5
22 | 8
23 | 6
24 | .
25 | j
26 | p
27 |
28 | t
29 | d
30 | 9
31 | 3
32 | e
33 | š
34 | 4
35 | k
36 | u
37 | ć
38 | c
39 | n
40 | đ
41 | o
42 | z
43 | č
44 | b
45 | ž
46 | f
47 | Z
48 | T
49 | h
50 | M
51 | F
52 | O
53 | Š
54 | B
55 | H
56 | A
57 | E
58 | Đ
59 | Ž
60 | D
61 | P
62 | G
63 | Č
64 | K
65 | U
66 | N
67 | J
68 | Ć
69 | w
70 | y
71 | W
72 | x
73 | Y
74 | X
75 | q
76 | Q
77 | #
78 | &
79 | $
80 | ,
81 | -
82 | %
83 | '
84 | @
85 | !
86 | :
87 | ?
88 | (
89 | É
90 | é
91 | +
92 |
--------------------------------------------------------------------------------
/ppocr/utils/dict/rsc_dict.txt:
--------------------------------------------------------------------------------
1 | r
2 | s
3 | c
4 | _
5 | i
6 | m
7 | g
8 | /
9 | 5
10 | I
11 | L
12 | S
13 | V
14 | R
15 | C
16 | 2
17 | 0
18 | 1
19 | v
20 | a
21 | l
22 | 9
23 | 7
24 | 8
25 | .
26 | j
27 | p
28 | м
29 | а
30 | с
31 | и
32 | р
33 | ћ
34 | е
35 | ш
36 | 3
37 | 4
38 | о
39 | г
40 | н
41 | з
42 | в
43 | л
44 | 6
45 | т
46 | ж
47 | у
48 | к
49 | п
50 | њ
51 | д
52 | ч
53 | С
54 | ј
55 | ф
56 | ц
57 | љ
58 | х
59 | О
60 | И
61 | А
62 | б
63 | Ш
64 | К
65 | ђ
66 | џ
67 | М
68 | В
69 | З
70 | Д
71 | Р
72 | У
73 | Н
74 | Т
75 | Б
76 | ?
77 | П
78 | Х
79 | Ј
80 | Ц
81 | Г
82 | Љ
83 | Л
84 | Ф
85 | e
86 | n
87 | w
88 | E
89 | F
90 | A
91 | N
92 | f
93 | o
94 | b
95 | M
96 | G
97 | t
98 | y
99 | W
100 | k
101 | P
102 | u
103 | H
104 | B
105 | T
106 | z
107 | h
108 | O
109 | Y
110 | d
111 | U
112 | K
113 | D
114 | x
115 | X
116 | J
117 | Z
118 | Q
119 | q
120 | '
121 | -
122 | @
123 | é
124 | #
125 | !
126 | ,
127 | %
128 | $
129 | :
130 | &
131 | +
132 | (
133 | É
134 |
135 |
--------------------------------------------------------------------------------
/ppocr/utils/dict/ru_dict.txt:
--------------------------------------------------------------------------------
1 | к
2 | в
3 | а
4 | з
5 | и
6 | у
7 | р
8 | о
9 | н
10 | я
11 | х
12 | п
13 | л
14 | ы
15 | г
16 | е
17 | т
18 | м
19 | д
20 | ж
21 | ш
22 | ь
23 | с
24 | ё
25 | б
26 | й
27 | ч
28 | ю
29 | ц
30 | щ
31 | М
32 | э
33 | ф
34 | А
35 | ъ
36 | С
37 | Ф
38 | Ю
39 | В
40 | К
41 | Т
42 | Н
43 | О
44 | Э
45 | У
46 | И
47 | Г
48 | Л
49 | Р
50 | Д
51 | Б
52 | Ш
53 | П
54 | З
55 | Х
56 | Е
57 | Ж
58 | Я
59 | Ц
60 | Ч
61 | Й
62 | Щ
63 | 0
64 | 1
65 | 2
66 | 3
67 | 4
68 | 5
69 | 6
70 | 7
71 | 8
72 | 9
73 | a
74 | b
75 | c
76 | d
77 | e
78 | f
79 | g
80 | h
81 | i
82 | j
83 | k
84 | l
85 | m
86 | n
87 | o
88 | p
89 | q
90 | r
91 | s
92 | t
93 | u
94 | v
95 | w
96 | x
97 | y
98 | z
99 | A
100 | B
101 | C
102 | D
103 | E
104 | F
105 | G
106 | H
107 | I
108 | J
109 | K
110 | L
111 | M
112 | N
113 | O
114 | P
115 | Q
116 | R
117 | S
118 | T
119 | U
120 | V
121 | W
122 | X
123 | Y
124 | Z
125 |
126 |
--------------------------------------------------------------------------------
/ppocr/utils/dict/spin_dict.txt:
--------------------------------------------------------------------------------
1 | 0
2 | 1
3 | 2
4 | 3
5 | 4
6 | 5
7 | 6
8 | 7
9 | 8
10 | 9
11 | a
12 | b
13 | c
14 | d
15 | e
16 | f
17 | g
18 | h
19 | i
20 | j
21 | k
22 | l
23 | m
24 | n
25 | o
26 | p
27 | q
28 | r
29 | s
30 | t
31 | u
32 | v
33 | w
34 | x
35 | y
36 | z
37 | :
38 | (
39 | '
40 | -
41 | ,
42 | %
43 | >
44 | .
45 | [
46 | ?
47 | )
48 | "
49 | =
50 | _
51 | *
52 | ]
53 | ;
54 | &
55 | +
56 | $
57 | @
58 | /
59 | |
60 | !
61 | <
62 | #
63 | `
64 | {
65 | ~
66 | \
67 | }
68 | ^
--------------------------------------------------------------------------------
/ppocr/utils/dict/ta_dict.txt:
--------------------------------------------------------------------------------
1 | t
2 | a
3 | _
4 | i
5 | m
6 | g
7 | /
8 | 3
9 | I
10 | L
11 | S
12 | V
13 | R
14 | C
15 | 2
16 | 0
17 | 1
18 | v
19 | l
20 | 9
21 | 7
22 | 8
23 | .
24 | j
25 | p
26 | ப
27 | ூ
28 | த
29 | ம
30 | ி
31 | வ
32 | ர
33 | ்
34 | ந
35 | ோ
36 | ன
37 | 6
38 | ஆ
39 | ற
40 | ல
41 | 5
42 | ள
43 | ா
44 | ொ
45 | ழ
46 | ு
47 | 4
48 | ெ
49 | ண
50 | க
51 | ட
52 | ை
53 | ே
54 | ச
55 | ய
56 | ஒ
57 | இ
58 | அ
59 | ங
60 | உ
61 | ீ
62 | ஞ
63 | எ
64 | ஓ
65 | ஃ
66 | ஜ
67 | ஷ
68 | ஸ
69 | ஏ
70 | ஊ
71 | ஹ
72 | ஈ
73 | ஐ
74 | ௌ
75 | ஔ
76 | s
77 | c
78 | e
79 | n
80 | w
81 | F
82 | T
83 | O
84 | P
85 | K
86 | A
87 | N
88 | G
89 | Y
90 | E
91 | M
92 | H
93 | U
94 | B
95 | o
96 | b
97 | D
98 | d
99 | r
100 | W
101 | u
102 | y
103 | f
104 | X
105 | k
106 | q
107 | h
108 | J
109 | z
110 | Z
111 | Q
112 | x
113 | -
114 | '
115 | $
116 | ,
117 | %
118 | @
119 | é
120 | !
121 | #
122 | +
123 | É
124 | &
125 | :
126 | (
127 | ?
128 |
129 |
--------------------------------------------------------------------------------
/ppocr/utils/dict/table_master_structure_dict.txt:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
6 |
4 |