├── .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 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | 13 | colspan="2" 14 | colspan="3" 15 | 16 | 17 | rowspan="2" 18 | colspan="4" 19 | colspan="6" 20 | rowspan="3" 21 | colspan="9" 22 | colspan="10" 23 | colspan="7" 24 | rowspan="4" 25 | rowspan="5" 26 | rowspan="9" 27 | colspan="8" 28 | rowspan="8" 29 | rowspan="6" 30 | rowspan="7" 31 | rowspan="10" 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /ppocr/utils/dict/table_structure_dict.txt: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | colspan="2" 13 | colspan="3" 14 | rowspan="2" 15 | colspan="4" 16 | colspan="6" 17 | rowspan="3" 18 | colspan="9" 19 | colspan="10" 20 | colspan="7" 21 | rowspan="4" 22 | rowspan="5" 23 | rowspan="9" 24 | colspan="8" 25 | rowspan="8" 26 | rowspan="6" 27 | rowspan="7" 28 | rowspan="10" -------------------------------------------------------------------------------- /ppocr/utils/dict/table_structure_dict_ch.txt: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 10 | 11 | colspan="2" 12 | colspan="3" 13 | colspan="4" 14 | colspan="5" 15 | colspan="6" 16 | colspan="7" 17 | colspan="8" 18 | colspan="9" 19 | colspan="10" 20 | colspan="11" 21 | colspan="12" 22 | colspan="13" 23 | colspan="14" 24 | colspan="15" 25 | colspan="16" 26 | colspan="17" 27 | colspan="18" 28 | colspan="19" 29 | colspan="20" 30 | rowspan="2" 31 | rowspan="3" 32 | rowspan="4" 33 | rowspan="5" 34 | rowspan="6" 35 | rowspan="7" 36 | rowspan="8" 37 | rowspan="9" 38 | rowspan="10" 39 | rowspan="11" 40 | rowspan="12" 41 | rowspan="13" 42 | rowspan="14" 43 | rowspan="15" 44 | rowspan="16" 45 | rowspan="17" 46 | rowspan="18" 47 | rowspan="19" 48 | rowspan="20" 49 | -------------------------------------------------------------------------------- /ppocr/utils/dict/te_dict.txt: -------------------------------------------------------------------------------- 1 | t 2 | e 3 | _ 4 | i 5 | m 6 | g 7 | / 8 | 5 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 | 3 22 | 4 23 | 8 24 | 9 25 | . 26 | j 27 | p 28 | త 29 | ె 30 | ర 31 | క 32 | ్ 33 | ి 34 | ం 35 | చ 36 | ే 37 | ద 38 | ు 39 | 7 40 | 6 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 | ఐ 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 | s 112 | c 113 | n 114 | w 115 | k 116 | J 117 | G 118 | u 119 | d 120 | r 121 | E 122 | o 123 | h 124 | y 125 | b 126 | f 127 | B 128 | M 129 | O 130 | T 131 | N 132 | D 133 | P 134 | A 135 | F 136 | x 137 | W 138 | Y 139 | U 140 | H 141 | K 142 | X 143 | z 144 | Z 145 | Q 146 | q 147 | É 148 | % 149 | # 150 | @ 151 | é 152 | -------------------------------------------------------------------------------- /ppocr/utils/dict/ug_dict.txt: -------------------------------------------------------------------------------- 1 | u 2 | g 3 | _ 4 | i 5 | m 6 | / 7 | 1 8 | I 9 | L 10 | S 11 | V 12 | R 13 | C 14 | 2 15 | 0 16 | v 17 | a 18 | l 19 | 8 20 | 5 21 | 3 22 | 6 23 | 9 24 | . 25 | j 26 | p 27 | 28 | ق 29 | ا 30 | پ 31 | ل 32 | 4 33 | 7 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 | s 64 | c 65 | e 66 | n 67 | w 68 | P 69 | E 70 | D 71 | U 72 | d 73 | r 74 | b 75 | y 76 | B 77 | o 78 | O 79 | Y 80 | N 81 | T 82 | k 83 | t 84 | h 85 | A 86 | H 87 | F 88 | z 89 | W 90 | K 91 | G 92 | M 93 | f 94 | Z 95 | X 96 | Q 97 | J 98 | x 99 | q 100 | - 101 | ! 102 | % 103 | # 104 | ? 105 | : 106 | $ 107 | , 108 | & 109 | ' 110 | É 111 | @ 112 | é 113 | ( 114 | + 115 | -------------------------------------------------------------------------------- /ppocr/utils/dict/uk_dict.txt: -------------------------------------------------------------------------------- 1 | u 2 | k 3 | _ 4 | i 5 | m 6 | g 7 | / 8 | 1 9 | 6 10 | I 11 | L 12 | S 13 | V 14 | R 15 | C 16 | 2 17 | 0 18 | v 19 | a 20 | l 21 | 7 22 | 9 23 | . 24 | j 25 | p 26 | в 27 | і 28 | д 29 | п 30 | о 31 | н 32 | с 33 | т 34 | ю 35 | 4 36 | 5 37 | 3 38 | а 39 | и 40 | м 41 | е 42 | р 43 | ч 44 | у 45 | Б 46 | з 47 | л 48 | к 49 | 8 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 | s 92 | c 93 | e 94 | n 95 | w 96 | A 97 | P 98 | r 99 | E 100 | t 101 | o 102 | h 103 | d 104 | y 105 | M 106 | G 107 | N 108 | F 109 | B 110 | T 111 | D 112 | U 113 | O 114 | W 115 | Z 116 | f 117 | H 118 | Y 119 | b 120 | K 121 | z 122 | x 123 | Q 124 | X 125 | q 126 | J 127 | $ 128 | - 129 | ' 130 | # 131 | & 132 | % 133 | ? 134 | : 135 | ! 136 | , 137 | + 138 | @ 139 | ( 140 | é 141 | É 142 | 143 | -------------------------------------------------------------------------------- /ppocr/utils/dict/ur_dict.txt: -------------------------------------------------------------------------------- 1 | u 2 | r 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 | a 20 | l 21 | 9 22 | 7 23 | 8 24 | . 25 | j 26 | p 27 | 28 | چ 29 | ٹ 30 | پ 31 | ا 32 | ئ 33 | ی 34 | ے 35 | 4 36 | 6 37 | و 38 | ل 39 | ن 40 | ڈ 41 | ھ 42 | ک 43 | ت 44 | ش 45 | ف 46 | ق 47 | ر 48 | د 49 | 5 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 | s 88 | c 89 | e 90 | n 91 | w 92 | o 93 | d 94 | t 95 | D 96 | M 97 | T 98 | U 99 | E 100 | b 101 | P 102 | h 103 | y 104 | W 105 | H 106 | A 107 | x 108 | B 109 | O 110 | N 111 | G 112 | Y 113 | Q 114 | F 115 | k 116 | K 117 | q 118 | J 119 | Z 120 | f 121 | z 122 | X 123 | ' 124 | @ 125 | & 126 | ! 127 | , 128 | : 129 | $ 130 | - 131 | # 132 | ? 133 | % 134 | é 135 | + 136 | ( 137 | É 138 | -------------------------------------------------------------------------------- /ppocr/utils/dict/xi_dict.txt: -------------------------------------------------------------------------------- 1 | x 2 | i 3 | _ 4 | m 5 | g 6 | / 7 | 1 8 | 0 9 | I 10 | L 11 | S 12 | V 13 | R 14 | C 15 | 2 16 | v 17 | a 18 | l 19 | 3 20 | 6 21 | 4 22 | 5 23 | . 24 | j 25 | p 26 | 27 | Q 28 | u 29 | e 30 | r 31 | o 32 | 8 33 | 7 34 | n 35 | c 36 | 9 37 | t 38 | b 39 | é 40 | q 41 | d 42 | ó 43 | y 44 | F 45 | s 46 | , 47 | O 48 | í 49 | T 50 | f 51 | " 52 | U 53 | M 54 | h 55 | : 56 | P 57 | H 58 | A 59 | E 60 | D 61 | z 62 | N 63 | á 64 | ñ 65 | ú 66 | % 67 | ; 68 | è 69 | + 70 | Y 71 | - 72 | B 73 | G 74 | ( 75 | ) 76 | ¿ 77 | ? 78 | w 79 | ¡ 80 | ! 81 | X 82 | É 83 | K 84 | k 85 | Á 86 | ü 87 | Ú 88 | « 89 | » 90 | J 91 | ' 92 | ö 93 | W 94 | Z 95 | º 96 | Ö 97 | ­ 98 | [ 99 | ] 100 | Ç 101 | ç 102 | à 103 | ä 104 | û 105 | ò 106 | Í 107 | ê 108 | ô 109 | ø 110 | ª 111 | -------------------------------------------------------------------------------- /ppocr/utils/dict90.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 | ~ -------------------------------------------------------------------------------- /ppocr/utils/en_dict.txt: -------------------------------------------------------------------------------- 1 | 0 2 | 1 3 | 2 4 | 3 5 | 4 6 | 5 7 | 6 8 | 7 9 | 8 10 | 9 11 | : 12 | ; 13 | < 14 | = 15 | > 16 | ? 17 | @ 18 | A 19 | B 20 | C 21 | D 22 | E 23 | F 24 | G 25 | H 26 | I 27 | J 28 | K 29 | L 30 | M 31 | N 32 | O 33 | P 34 | Q 35 | R 36 | S 37 | T 38 | U 39 | V 40 | W 41 | X 42 | Y 43 | Z 44 | [ 45 | \ 46 | ] 47 | ^ 48 | _ 49 | ` 50 | a 51 | b 52 | c 53 | d 54 | e 55 | f 56 | g 57 | h 58 | i 59 | j 60 | k 61 | l 62 | m 63 | n 64 | o 65 | p 66 | q 67 | r 68 | s 69 | t 70 | u 71 | v 72 | w 73 | x 74 | y 75 | z 76 | { 77 | | 78 | } 79 | ~ 80 | ! 81 | " 82 | # 83 | $ 84 | % 85 | & 86 | ' 87 | ( 88 | ) 89 | * 90 | + 91 | , 92 | - 93 | . 94 | / 95 | 96 | -------------------------------------------------------------------------------- /ppocr/utils/ic15_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 -------------------------------------------------------------------------------- /ppocr/utils/iou.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/loss/iou.py 17 | """ 18 | 19 | import paddle 20 | 21 | EPS = 1e-6 22 | 23 | 24 | def iou_single(a, b, mask, n_class): 25 | valid = mask == 1 26 | a = a.masked_select(valid) 27 | b = b.masked_select(valid) 28 | miou = [] 29 | for i in range(n_class): 30 | if a.shape == [0] and a.shape == b.shape: 31 | inter = paddle.to_tensor(0.0) 32 | union = paddle.to_tensor(0.0) 33 | else: 34 | inter = ((a == i).logical_and(b == i)).astype('float32') 35 | union = ((a == i).logical_or(b == i)).astype('float32') 36 | miou.append(paddle.sum(inter) / (paddle.sum(union) + EPS)) 37 | miou = sum(miou) / len(miou) 38 | return miou 39 | 40 | 41 | def iou(a, b, mask, n_class=2, reduce=True): 42 | batch_size = a.shape[0] 43 | 44 | a = a.reshape([batch_size, -1]) 45 | b = b.reshape([batch_size, -1]) 46 | mask = mask.reshape([batch_size, -1]) 47 | 48 | iou = paddle.zeros((batch_size, ), dtype='float32') 49 | for i in range(batch_size): 50 | iou[i] = iou_single(a[i], b[i], mask[i], n_class) 51 | 52 | if reduce: 53 | iou = paddle.mean(iou) 54 | return iou 55 | -------------------------------------------------------------------------------- /ppocr/utils/loggers/__init__.py: -------------------------------------------------------------------------------- 1 | from .vdl_logger import VDLLogger 2 | from .wandb_logger import WandbLogger 3 | from .loggers import Loggers 4 | -------------------------------------------------------------------------------- /ppocr/utils/loggers/base_logger.py: -------------------------------------------------------------------------------- 1 | import os 2 | from abc import ABC, abstractmethod 3 | 4 | class BaseLogger(ABC): 5 | def __init__(self, save_dir): 6 | self.save_dir = save_dir 7 | os.makedirs(self.save_dir, exist_ok=True) 8 | 9 | @abstractmethod 10 | def log_metrics(self, metrics, prefix=None): 11 | pass 12 | 13 | @abstractmethod 14 | def close(self): 15 | pass -------------------------------------------------------------------------------- /ppocr/utils/loggers/loggers.py: -------------------------------------------------------------------------------- 1 | from .wandb_logger import WandbLogger 2 | 3 | class Loggers(object): 4 | def __init__(self, loggers): 5 | super().__init__() 6 | self.loggers = loggers 7 | 8 | def log_metrics(self, metrics, prefix=None, step=None): 9 | for logger in self.loggers: 10 | logger.log_metrics(metrics, prefix=prefix, step=step) 11 | 12 | def log_model(self, is_best, prefix, metadata=None): 13 | for logger in self.loggers: 14 | logger.log_model(is_best=is_best, prefix=prefix, metadata=metadata) 15 | 16 | def close(self): 17 | for logger in self.loggers: 18 | logger.close() -------------------------------------------------------------------------------- /ppocr/utils/loggers/vdl_logger.py: -------------------------------------------------------------------------------- 1 | from .base_logger import BaseLogger 2 | from visualdl import LogWriter 3 | 4 | class VDLLogger(BaseLogger): 5 | def __init__(self, save_dir): 6 | super().__init__(save_dir) 7 | self.vdl_writer = LogWriter(logdir=save_dir) 8 | 9 | def log_metrics(self, metrics, prefix=None, step=None): 10 | if not prefix: 11 | prefix = "" 12 | updated_metrics = {prefix + "/" + k: v for k, v in metrics.items()} 13 | 14 | for k, v in updated_metrics.items(): 15 | self.vdl_writer.add_scalar(k, v, step) 16 | 17 | def log_model(self, is_best, prefix, metadata=None): 18 | pass 19 | 20 | def close(self): 21 | self.vdl_writer.close() -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | shapely 2 | scikit-image 3 | imgaug 4 | pyclipper 5 | lmdb 6 | tqdm 7 | numpy 8 | tensorboard 9 | rapidfuzz 10 | opencv-python 11 | cython 12 | attrdict 13 | pyyaml 14 | onnxruntime -------------------------------------------------------------------------------- /tools/eval.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # @Time : 2023/8/26 15:23 3 | # @Author : zhoujun 4 | import os 5 | import sys 6 | 7 | __dir__ = os.path.dirname(os.path.abspath(__file__)) 8 | 9 | sys.path.append(__dir__) 10 | sys.path.insert(0, os.path.abspath(os.path.join(__dir__, '..'))) 11 | 12 | from tools.utility import ArgsParser 13 | from torchocr import Config 14 | from torchocr import Trainer 15 | 16 | 17 | def parse_args(): 18 | parser = ArgsParser() 19 | args = parser.parse_args() 20 | return args 21 | 22 | 23 | def main(): 24 | FLAGS = parse_args() 25 | cfg = Config(FLAGS.config) 26 | FLAGS = vars(FLAGS) 27 | opt = FLAGS.pop('opt') 28 | cfg.merge_dict(opt) 29 | trainer = Trainer(cfg, mode='eval') 30 | 31 | best_model_dict = trainer.status.get('metrics', {}) 32 | trainer.logger.info('metric in ckpt ***************') 33 | for k, v in best_model_dict.items(): 34 | trainer.logger.info('{}:{}'.format(k, v)) 35 | 36 | metric = trainer.eval() 37 | 38 | trainer.logger.info('metric eval ***************') 39 | for k, v in metric.items(): 40 | trainer.logger.info('{}:{}'.format(k, v)) 41 | 42 | 43 | if __name__ == '__main__': 44 | main() 45 | -------------------------------------------------------------------------------- /tools/train.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # @Time : 2023/8/26 15:23 3 | # @Author : zhoujun 4 | import os 5 | import sys 6 | __dir__ = os.path.dirname(os.path.abspath(__file__)) 7 | 8 | sys.path.append(__dir__) 9 | sys.path.insert(0, os.path.abspath(os.path.join(__dir__, '..'))) 10 | 11 | from tools.utility import ArgsParser 12 | from torchocr import Config 13 | from torchocr import Trainer 14 | 15 | 16 | def parse_args(): 17 | parser = ArgsParser() 18 | parser.add_argument( 19 | "--eval", 20 | action='store_true', 21 | default=True, 22 | help="Whether to perform evaluation in train") 23 | args = parser.parse_args() 24 | return args 25 | 26 | 27 | def main(): 28 | FLAGS = parse_args() 29 | cfg = Config(FLAGS.config) 30 | FLAGS = vars(FLAGS) 31 | opt = FLAGS.pop('opt') 32 | cfg.merge_dict(opt) 33 | trainer = Trainer(cfg, mode='train_eval' if FLAGS['eval'] else 'train') 34 | trainer.train() 35 | 36 | 37 | if __name__ == '__main__': 38 | main() 39 | -------------------------------------------------------------------------------- /torchocr/__init__.py: -------------------------------------------------------------------------------- 1 | from .engine import Config, Trainer -------------------------------------------------------------------------------- /torchocr/data/cache.py: -------------------------------------------------------------------------------- 1 | import os 2 | import shutil 3 | import traceback 4 | from pathlib import Path 5 | from torchocr.utils.logging import get_logger 6 | 7 | def cache(image_path, cache_dir, force_cache=False): 8 | if isinstance(image_path, Path): 9 | image_path = str(image_path) 10 | 11 | image = None 12 | img_save_path = f'{cache_dir}/{image_path}' 13 | 14 | if os.path.exists(img_save_path): 15 | return img_save_path 16 | 17 | os.makedirs(os.path.split(img_save_path)[0], exist_ok=True) 18 | 19 | if force_cache or not os.path.exists(img_save_path): 20 | shutil.copy2(image_path, img_save_path) 21 | 22 | if os.path.exists(img_save_path): 23 | return img_save_path 24 | else: 25 | logger = get_logger() 26 | logger.error(f'Failed to cache image {image_path}') 27 | return image_path -------------------------------------------------------------------------------- /torchocr/data/imaug/ColorJitter.py: -------------------------------------------------------------------------------- 1 | from torchvision.transforms import ColorJitter as _ColorJitter 2 | 3 | __all__ = ['ColorJitter'] 4 | 5 | class ColorJitter(object): 6 | def __init__(self, brightness=0, contrast=0, saturation=0, hue=0,**kwargs): 7 | self.aug = _ColorJitter(brightness, contrast, saturation, hue) 8 | 9 | def __call__(self, data): 10 | image = data['image'] 11 | image = self.aug(image) 12 | data['image'] = image 13 | return data 14 | -------------------------------------------------------------------------------- /torchocr/data/imaug/randaugment.py: -------------------------------------------------------------------------------- 1 | from PIL import Image 2 | import numpy as np 3 | from torchvision.transforms import RandAugment as RawRandAugment 4 | 5 | class RandAugment(RawRandAugment): 6 | def __init__(self, prob=0.5, *args, **kwargs): 7 | super().__init__() 8 | self.prob = prob 9 | 10 | def __call__(self, data): 11 | if np.random.rand() > self.prob: 12 | return data 13 | img = data['image'] 14 | if not isinstance(img, Image.Image): 15 | img = Image.fromarray(img) 16 | 17 | img = super().__call__(img) 18 | 19 | if isinstance(img, Image.Image): 20 | img = np.asarray(img) 21 | data['image'] = img 22 | return data 23 | -------------------------------------------------------------------------------- /torchocr/data/imaug/ssl_img_aug.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | import numpy as np 3 | 4 | from .rec_img_aug import resize_norm_img 5 | 6 | 7 | class SSLRotateResize(object): 8 | def __init__(self, 9 | image_shape, 10 | padding=False, 11 | select_all=True, 12 | mode="train", 13 | **kwargs): 14 | self.image_shape = image_shape 15 | self.padding = padding 16 | self.select_all = select_all 17 | self.mode = mode 18 | 19 | def __call__(self, data): 20 | img = data["image"] 21 | 22 | data["image_r90"] = cv2.rotate(img, cv2.ROTATE_90_CLOCKWISE) 23 | data["image_r180"] = cv2.rotate(data["image_r90"], 24 | cv2.ROTATE_90_CLOCKWISE) 25 | data["image_r270"] = cv2.rotate(data["image_r180"], 26 | cv2.ROTATE_90_CLOCKWISE) 27 | 28 | images = [] 29 | for key in ["image", "image_r90", "image_r180", "image_r270"]: 30 | images.append( 31 | resize_norm_img( 32 | data.pop(key), 33 | image_shape=self.image_shape, 34 | padding=self.padding)[0]) 35 | data["image"] = np.stack(images, axis=0) 36 | data["label"] = np.array(list(range(4))) 37 | if not self.select_all: 38 | data["image"] = data["image"][0::2] # just choose 0 and 180 39 | data["label"] = data["label"][0:2] # label needs to be continuous 40 | if self.mode == "test": 41 | data["image"] = data["image"][0] 42 | data["label"] = data["label"][0] 43 | return data 44 | -------------------------------------------------------------------------------- /torchocr/data/imaug/text_image_aug/__init__.py: -------------------------------------------------------------------------------- 1 | from .augment import tia_perspective, tia_distort, tia_stretch 2 | 3 | __all__ = ['tia_distort', 'tia_stretch', 'tia_perspective'] 4 | -------------------------------------------------------------------------------- /torchocr/engine/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # @Time : 2023/8/26 11:34 3 | # @Author : zhoujun 4 | 5 | from . import config 6 | from . import trainer 7 | from .config import * 8 | from .trainer import * 9 | 10 | __all__ = config.__all__ + trainer.__all__ 11 | -------------------------------------------------------------------------------- /torchocr/losses/ace_loss.py: -------------------------------------------------------------------------------- 1 | import torch 2 | import torch.nn as nn 3 | 4 | 5 | class ACELoss(nn.Module): 6 | def __init__(self, **kwargs): 7 | super().__init__() 8 | self.loss_func = nn.CrossEntropyLoss( 9 | weight=None, 10 | ignore_index=0, 11 | reduction='none', 12 | soft_label=True, 13 | dim=-1) 14 | 15 | def __call__(self, predicts, batch): 16 | if isinstance(predicts, (list, tuple)): 17 | predicts = predicts[-1] 18 | 19 | B, N = predicts.shape[:2] 20 | div = torch.tensor([N]).astype('float32') 21 | 22 | predicts = nn.functional.softmax(predicts, dim=-1) 23 | aggregation_preds = torch.sum(predicts, dim=1) 24 | aggregation_preds = torch.divide(aggregation_preds, div) 25 | 26 | length = batch[2].astype("float32") 27 | batch = batch[3].astype("float32") 28 | batch[:, 0] = torch.subtract(div, length) 29 | batch = torch.divide(batch, div) 30 | 31 | loss = self.loss_func(aggregation_preds, batch) 32 | return {"loss_ace": loss} 33 | -------------------------------------------------------------------------------- /torchocr/losses/cls_loss.py: -------------------------------------------------------------------------------- 1 | from torch import nn 2 | 3 | 4 | class ClsLoss(nn.Module): 5 | def __init__(self, **kwargs): 6 | super(ClsLoss, self).__init__() 7 | self.loss_func = nn.CrossEntropyLoss(reduction='mean') 8 | 9 | def forward(self, predicts, batch): 10 | label = batch[1].long() 11 | loss = self.loss_func(predicts['res'], label) 12 | return {'loss': loss} 13 | -------------------------------------------------------------------------------- /torchocr/losses/det_east_loss.py: -------------------------------------------------------------------------------- 1 | import torch 2 | from torch import nn 3 | from .det_basic_loss import DiceLoss 4 | 5 | 6 | class EASTLoss(nn.Module): 7 | """ 8 | """ 9 | 10 | def __init__(self, 11 | eps=1e-6, 12 | **kwargs): 13 | super(EASTLoss, self).__init__() 14 | self.dice_loss = DiceLoss(eps=eps) 15 | 16 | def forward(self, predicts, labels): 17 | l_score, l_geo, l_mask = labels[1:] 18 | f_score = predicts['f_score'] 19 | f_geo = predicts['f_geo'] 20 | 21 | dice_loss = self.dice_loss(f_score, l_score, l_mask) 22 | 23 | #smoooth_l1_loss 24 | channels = 8 25 | l_geo_split = torch.split(l_geo, split_size_or_sections=channels + 1, dim=1) 26 | f_geo_split = torch.split(f_geo, split_size_or_sections=channels, dim=1) 27 | smooth_l1 = 0 28 | for i in range(0, channels): 29 | geo_diff = l_geo_split[i] - f_geo_split[i] 30 | abs_geo_diff = torch.abs(geo_diff) 31 | smooth_l1_sign = (abs_geo_diff < l_score).float() 32 | in_loss = abs_geo_diff * abs_geo_diff * smooth_l1_sign + \ 33 | (abs_geo_diff - 0.5) * (1.0 - smooth_l1_sign) 34 | out_loss = l_geo_split[-1] / channels * in_loss * l_score 35 | smooth_l1 += out_loss 36 | smooth_l1_loss = torch.mean(smooth_l1 * l_score) 37 | 38 | dice_loss = dice_loss * 0.01 39 | total_loss = dice_loss + smooth_l1_loss 40 | losses = {"loss":total_loss, \ 41 | "dice_loss":dice_loss,\ 42 | "smooth_l1_loss":smooth_l1_loss} 43 | return losses 44 | -------------------------------------------------------------------------------- /torchocr/losses/rec_att_loss.py: -------------------------------------------------------------------------------- 1 | import torch 2 | from torch import nn 3 | 4 | 5 | class AttentionLoss(nn.Module): 6 | def __init__(self, **kwargs): 7 | super(AttentionLoss, self).__init__() 8 | self.loss_func = nn.CrossEntropyLoss(weight=None, reduction='none') 9 | 10 | def forward(self, predicts, batch): 11 | predicts = predicts['res'][:, :-1] 12 | targets = batch[1].long()[:,1:] 13 | assert len(targets.shape) == len(list(predicts.shape)) - 1, \ 14 | "The target's shape and inputs's shape is [N, d] and [N, num_steps]" 15 | 16 | inputs = torch.reshape(predicts, [-1, predicts.shape[-1]]) 17 | targets = torch.reshape(targets, [-1]) 18 | 19 | return {'loss': torch.sum(self.loss_func(inputs, targets))} 20 | -------------------------------------------------------------------------------- /torchocr/losses/rec_ctc_loss.py: -------------------------------------------------------------------------------- 1 | import torch 2 | from torch import nn 3 | 4 | 5 | class CTCLoss(nn.Module): 6 | def __init__(self, use_focal_loss=False, **kwargs): 7 | super(CTCLoss, self).__init__() 8 | self.loss_func = nn.CTCLoss(blank=0, reduction='none') 9 | self.use_focal_loss = use_focal_loss 10 | 11 | def forward(self, predicts, batch): 12 | predicts = predicts['res'] 13 | 14 | batch_size = predicts.size(0) 15 | label, label_length = batch[1], batch[2] 16 | predicts = predicts.log_softmax(2) 17 | predicts = predicts.permute(1, 0, 2) 18 | preds_lengths = torch.tensor([predicts.size(0)] * batch_size, dtype=torch.long) 19 | loss = self.loss_func(predicts, label, preds_lengths, label_length) 20 | 21 | if self.use_focal_loss: 22 | weight = torch.exp(-loss) 23 | weight = 1 - weight 24 | weight = torch.square(weight) 25 | loss = loss * weight 26 | loss = loss.mean() 27 | return {'loss': loss} 28 | -------------------------------------------------------------------------------- /torchocr/losses/rec_enhanced_ctc_loss.py: -------------------------------------------------------------------------------- 1 | from torch import nn 2 | from .ace_loss import ACELoss 3 | from .center_loss import CenterLoss 4 | from .rec_ctc_loss import CTCLoss 5 | 6 | 7 | class EnhancedCTCLoss(nn.Module): 8 | def __init__(self, 9 | use_focal_loss=False, 10 | use_ace_loss=False, 11 | ace_loss_weight=0.1, 12 | use_center_loss=False, 13 | center_loss_weight=0.05, 14 | num_classes=6625, 15 | feat_dim=96, 16 | init_center=False, 17 | center_file_path=None, 18 | **kwargs): 19 | super(EnhancedCTCLoss, self).__init__() 20 | self.ctc_loss_func = CTCLoss(use_focal_loss=use_focal_loss) 21 | 22 | self.use_ace_loss = False 23 | if use_ace_loss: 24 | self.use_ace_loss = use_ace_loss 25 | self.ace_loss_func = ACELoss() 26 | self.ace_loss_weight = ace_loss_weight 27 | 28 | self.use_center_loss = False 29 | if use_center_loss: 30 | self.use_center_loss = use_center_loss 31 | self.center_loss_func = CenterLoss( 32 | num_classes=num_classes, 33 | feat_dim=feat_dim, 34 | center_file_path=center_file_path) 35 | self.center_loss_weight = center_loss_weight 36 | 37 | def __call__(self, predicts, batch): 38 | loss = self.ctc_loss_func(predicts, batch)["loss"] 39 | 40 | if self.use_center_loss: 41 | center_loss = self.center_loss_func( 42 | predicts, batch)["loss_center"] * self.center_loss_weight 43 | loss = loss + center_loss 44 | 45 | if self.use_ace_loss: 46 | ace_loss = self.ace_loss_func( 47 | predicts, batch)["loss_ace"] * self.ace_loss_weight 48 | loss = loss + ace_loss 49 | 50 | return {'enhanced_ctc_loss': loss} 51 | -------------------------------------------------------------------------------- /torchocr/losses/rec_multi_loss.py: -------------------------------------------------------------------------------- 1 | from torch import nn 2 | 3 | from .rec_ctc_loss import CTCLoss 4 | from .rec_sar_loss import SARLoss 5 | from .rec_nrtr_loss import NRTRLoss 6 | class MultiLoss(nn.Module): 7 | def __init__(self, **kwargs): 8 | super().__init__() 9 | self.loss_funcs = {} 10 | self.loss_list = kwargs.pop('loss_config_list') 11 | self.weight_1 = kwargs.get('weight_1', 1.0) 12 | self.weight_2 = kwargs.get('weight_2', 1.0) 13 | for loss_info in self.loss_list: 14 | for name, param in loss_info.items(): 15 | if param is not None: 16 | kwargs.update(param) 17 | loss = eval(name)(**kwargs) 18 | self.loss_funcs[name] = loss 19 | 20 | def forward(self, predicts, batch): 21 | self.total_loss = {} 22 | total_loss = 0.0 23 | # batch [image, label_ctc, label_sar, length, valid_ratio] 24 | for name, loss_func in self.loss_funcs.items(): 25 | if name == 'CTCLoss': 26 | loss = loss_func({'res': predicts['ctc']}, batch[:2] + batch[3:])['loss'] * self.weight_1 27 | elif name == 'SARLoss': 28 | loss = loss_func({'res': predicts['sar']}, batch[:1] + batch[2:])['loss'] * self.weight_2 29 | elif name == 'NRTRLoss': 30 | loss = loss_func({'res': predicts['nrtr']}, batch[:1] + batch[2:])['loss'] * self.weight_2 31 | else: 32 | raise NotImplementedError( 33 | '{} is not supported in MultiLoss yet'.format(name)) 34 | self.total_loss[name] = loss 35 | total_loss += loss 36 | self.total_loss['loss'] = total_loss 37 | return self.total_loss 38 | -------------------------------------------------------------------------------- /torchocr/losses/rec_nrtr_loss.py: -------------------------------------------------------------------------------- 1 | import torch 2 | from torch import nn 3 | import torch.nn.functional as F 4 | 5 | 6 | class NRTRLoss(nn.Module): 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 | pred = pred['res'] 16 | max_len = batch[2].max() 17 | tgt = batch[1][:, 1:2 + max_len] 18 | pred = pred.reshape([-1, pred.shape[2]]) 19 | tgt = tgt.reshape([-1]) 20 | if self.smoothing: 21 | eps = 0.1 22 | n_class = pred.shape[1] 23 | one_hot = F.one_hot(tgt.long(), num_classes=pred.shape[1]) 24 | one_hot = one_hot * (1 - eps) + (1 - one_hot) * eps / (n_class - 1) 25 | log_prb = F.log_softmax(pred, dim=1) 26 | non_pad_mask = torch.not_equal(tgt, torch.zeros(tgt.shape, dtype=tgt.dtype, device=tgt.device)) 27 | loss = -(one_hot * log_prb).sum(dim=1) 28 | loss = loss.masked_select(non_pad_mask).mean() 29 | else: 30 | loss = self.loss_func(pred, tgt) 31 | return {'loss': loss} 32 | -------------------------------------------------------------------------------- /torchocr/losses/rec_pren_loss.py: -------------------------------------------------------------------------------- 1 | from torch import nn 2 | 3 | 4 | class PRENLoss(nn.Module): 5 | def __init__(self, **kwargs): 6 | super(PRENLoss, self).__init__() 7 | # note: 0 is padding idx 8 | self.loss_func = nn.CrossEntropyLoss(reduction='mean', ignore_index=0) 9 | 10 | def forward(self, predicts, batch): 11 | loss = self.loss_func(predicts, batch[1].astype('int64')) 12 | return {'loss': loss} 13 | -------------------------------------------------------------------------------- /torchocr/losses/rec_rfl_loss.py: -------------------------------------------------------------------------------- 1 | import torch 2 | from torch import nn 3 | 4 | from .basic_loss import CELoss, DistanceLoss 5 | 6 | 7 | class RFLLoss(nn.Module): 8 | def __init__(self, ignore_index=-100, **kwargs): 9 | super().__init__() 10 | 11 | self.cnt_loss = nn.MSELoss(**kwargs) 12 | self.seq_loss = nn.CrossEntropyLoss(ignore_index=ignore_index) 13 | 14 | def forward(self, predicts, batch): 15 | 16 | self.total_loss = {} 17 | total_loss = 0.0 18 | if isinstance(predicts, tuple) or isinstance(predicts, list): 19 | cnt_outputs, seq_outputs = predicts 20 | else: 21 | cnt_outputs, seq_outputs = predicts, None 22 | # batch [image, label, length, cnt_label] 23 | if cnt_outputs is not None: 24 | cnt_loss = self.cnt_loss(cnt_outputs,batch[3].float()) 25 | self.total_loss['cnt_loss'] = cnt_loss 26 | total_loss += cnt_loss 27 | 28 | if seq_outputs is not None: 29 | targets = batch[1].astype("int64") 30 | label_lengths = batch[2].astype('int64') 31 | batch_size, num_steps, num_classes = seq_outputs.shape[ 32 | 0], seq_outputs.shape[1], seq_outputs.shape[2] 33 | assert len(targets.shape) == len(list(seq_outputs.shape)) - 1, \ 34 | "The target's shape and inputs's shape is [N, d] and [N, num_steps]" 35 | 36 | inputs = seq_outputs[:, :-1, :] 37 | targets = targets[:, 1:] 38 | 39 | inputs = torch.reshape(inputs, [-1, inputs.shape[-1]]) 40 | targets = torch.reshape(targets, [-1]) 41 | seq_loss = self.seq_loss(inputs, targets) 42 | self.total_loss['seq_loss'] = seq_loss 43 | total_loss += seq_loss 44 | 45 | self.total_loss['loss'] = total_loss 46 | return self.total_loss 47 | -------------------------------------------------------------------------------- /torchocr/losses/rec_sar_loss.py: -------------------------------------------------------------------------------- 1 | from torch import nn 2 | 3 | 4 | class SARLoss(nn.Module): 5 | def __init__(self, **kwargs): 6 | super(SARLoss, self).__init__() 7 | ignore_index = kwargs.get('ignore_index', 92) # 6626 8 | self.loss_func = nn.CrossEntropyLoss(reduction="mean", ignore_index=ignore_index) 9 | 10 | def forward(self, predicts, batch): 11 | predicts = predicts['res'] 12 | predict = predicts[:, :-1, :] # ignore last index of outputs to be in same seq_len with targets 13 | label = batch[1].long()[:, 1:] # ignore first index of target in loss calculation 14 | batch_size, num_steps, num_classes = predict.shape[0], predict.shape[1], predict.shape[2] 15 | assert len(label.shape) == len(list(predict.shape)) - 1, \ 16 | "The target's shape and inputs's shape is [N, d] and [N, num_steps]" 17 | 18 | inputs = predict.reshape([-1, num_classes]) 19 | targets = label.reshape([-1]) 20 | loss = self.loss_func(inputs, targets) 21 | return {'loss': loss} 22 | -------------------------------------------------------------------------------- /torchocr/losses/rec_satrn_loss.py: -------------------------------------------------------------------------------- 1 | import torch 2 | from torch import nn 3 | 4 | 5 | class SATRNLoss(nn.Module): 6 | def __init__(self, **kwargs): 7 | super(SATRNLoss, self).__init__() 8 | ignore_index = kwargs.get('ignore_index', 92) # 6626 9 | self.loss_func = nn.CrossEntropyLoss( 10 | reduction="none", ignore_index=ignore_index) 11 | 12 | def forward(self, predicts, batch): 13 | predict = predicts[:, : 14 | -1, :] # ignore last index of outputs to be in same seq_len with targets 15 | label = batch[1].astype( 16 | "int64")[:, 1:] # ignore first index of target in loss calculation 17 | batch_size, num_steps, num_classes = predict.shape[0], predict.shape[ 18 | 1], predict.shape[2] 19 | assert len(label.shape) == len(list(predict.shape)) - 1, \ 20 | "The target's shape and inputs's shape is [N, d] and [N, num_steps]" 21 | 22 | inputs = torch.reshape(predict, [-1, num_classes]) 23 | targets = torch.reshape(label, [-1]) 24 | loss = self.loss_func(inputs, targets) 25 | return {'loss': loss.mean()} 26 | -------------------------------------------------------------------------------- /torchocr/losses/rec_spin_att_loss.py: -------------------------------------------------------------------------------- 1 | import torch 2 | from torch import nn 3 | 4 | class SPINAttentionLoss(nn.Module): 5 | def __init__(self, reduction='mean', ignore_index=-100, **kwargs): 6 | super(SPINAttentionLoss, self).__init__() 7 | self.loss_func = nn.CrossEntropyLoss(weight=None, reduction=reduction, ignore_index=ignore_index) 8 | 9 | def forward(self, predicts, batch): 10 | targets = batch[1].astype("int64") 11 | targets = targets[:, 1:] # remove [eos] in label 12 | 13 | label_lengths = batch[2].astype('int64') 14 | batch_size, num_steps, num_classes = predicts.shape[0], predicts.shape[ 15 | 1], predicts.shape[2] 16 | assert len(targets.shape) == len(list(predicts.shape)) - 1, \ 17 | "The target's shape and inputs's shape is [N, d] and [N, num_steps]" 18 | 19 | inputs = torch.reshape(predicts, [-1, predicts.shape[-1]]) 20 | targets = torch.reshape(targets, [-1]) 21 | 22 | return {'loss': self.loss_func(inputs, targets)} 23 | -------------------------------------------------------------------------------- /torchocr/losses/rec_srn_loss.py: -------------------------------------------------------------------------------- 1 | import torch 2 | from torch import nn 3 | 4 | 5 | class SRNLoss(nn.Module): 6 | def __init__(self, **kwargs): 7 | super(SRNLoss, self).__init__() 8 | self.loss_func = nn.CrossEntropyLoss(reduction="sum") 9 | 10 | def forward(self, predicts, batch): 11 | predict = predicts['predict'] 12 | word_predict = predicts['word_out'] 13 | gsrm_predict = predicts['gsrm_out'] 14 | label = batch[1] 15 | 16 | casted_label = label.long() 17 | casted_label = label.reshape(x=casted_label, shape=[-1, 1]) 18 | 19 | cost_word = self.loss_func(word_predict, label=casted_label) 20 | cost_gsrm = self.loss_func(gsrm_predict, label=casted_label) 21 | cost_vsfd = self.loss_func(predict, label=casted_label) 22 | 23 | cost_word = label.reshape(x=label.sum(cost_word), shape=[1]) 24 | cost_gsrm = label.reshape(x=label.sum(cost_gsrm), shape=[1]) 25 | cost_vsfd = label.reshape(x=label.sum(cost_vsfd), shape=[1]) 26 | 27 | sum_cost = cost_word * 3.0 + cost_vsfd + cost_gsrm * 0.15 28 | 29 | return {'loss': sum_cost, 'word_loss': cost_word, 'img_loss': cost_vsfd} 30 | -------------------------------------------------------------------------------- /torchocr/losses/stroke_focus_loss.py: -------------------------------------------------------------------------------- 1 | import torch 2 | import torch.nn as nn 3 | 4 | 5 | class StrokeFocusLoss(nn.Module): 6 | def __init__(self, character_dict_path=None, **kwargs): 7 | super(StrokeFocusLoss, self).__init__(character_dict_path) 8 | self.mse_loss = nn.MSELoss() 9 | self.ce_loss = nn.CrossEntropyLoss() 10 | self.l1_loss = nn.L1Loss() 11 | self.english_stroke_alphabet = '0123456789' 12 | self.english_stroke_dict = {} 13 | for index in range(len(self.english_stroke_alphabet)): 14 | self.english_stroke_dict[self.english_stroke_alphabet[ 15 | index]] = index 16 | 17 | stroke_decompose_lines = open(character_dict_path, 'r').readlines() 18 | self.dic = {} 19 | for line in stroke_decompose_lines: 20 | line = line.strip() 21 | character, sequence = line.split() 22 | self.dic[character] = sequence 23 | 24 | def forward(self, pred, data): 25 | 26 | sr_img = pred["sr_img"] 27 | hr_img = pred["hr_img"] 28 | 29 | mse_loss = self.mse_loss(sr_img, hr_img) 30 | word_attention_map_gt = pred["word_attention_map_gt"] 31 | word_attention_map_pred = pred["word_attention_map_pred"] 32 | 33 | hr_pred = pred["hr_pred"] 34 | sr_pred = pred["sr_pred"] 35 | 36 | attention_loss = torch.nn.functional.l1_loss(word_attention_map_gt, 37 | word_attention_map_pred) 38 | 39 | loss = (mse_loss + attention_loss * 50) * 100 40 | 41 | return { 42 | "mse_loss": mse_loss, 43 | "attention_loss": attention_loss, 44 | "loss": loss 45 | } 46 | -------------------------------------------------------------------------------- /torchocr/metrics/__init__.py: -------------------------------------------------------------------------------- 1 | import copy 2 | 3 | __all__ = ["build_metric"] 4 | 5 | from .det_metric import DetMetric, DetFCEMetric 6 | from .rec_metric import RecMetric, CNTMetric, CANMetric 7 | from .cls_metric import ClsMetric 8 | from .e2e_metric import E2EMetric 9 | from .distillation_metric import DistillationMetric 10 | 11 | 12 | def build_metric(config): 13 | support_dict = [ 14 | "DetMetric", "DetFCEMetric", "RecMetric", "ClsMetric", "E2EMetric", 15 | "DistillationMetric" 16 | ] 17 | 18 | config = copy.deepcopy(config) 19 | module_name = config.pop("name") 20 | assert module_name in support_dict, Exception( 21 | "metric only support {}".format(support_dict)) 22 | module_class = eval(module_name)(**config) 23 | return module_class 24 | -------------------------------------------------------------------------------- /torchocr/metrics/cls_metric.py: -------------------------------------------------------------------------------- 1 | class ClsMetric(object): 2 | def __init__(self, main_indicator='acc', **kwargs): 3 | self.main_indicator = main_indicator 4 | self.eps = 1e-5 5 | self.reset() 6 | 7 | def __call__(self, pred_label, *args, **kwargs): 8 | preds, labels = pred_label 9 | correct_num = 0 10 | all_num = 0 11 | for (pred, pred_conf), (target, _) in zip(preds, labels): 12 | if pred == target: 13 | correct_num += 1 14 | all_num += 1 15 | self.correct_num += correct_num 16 | self.all_num += all_num 17 | return {'acc': correct_num / (all_num + self.eps), } 18 | 19 | def get_metric(self): 20 | """ 21 | return metrics { 22 | 'acc': 0 23 | } 24 | """ 25 | acc = self.correct_num / (self.all_num + self.eps) 26 | self.reset() 27 | return {'acc': acc} 28 | 29 | def reset(self): 30 | self.correct_num = 0 31 | self.all_num = 0 32 | -------------------------------------------------------------------------------- /torchocr/metrics/distillation_metric.py: -------------------------------------------------------------------------------- 1 | import importlib 2 | import copy 3 | 4 | from .rec_metric import RecMetric 5 | from .det_metric import DetMetric 6 | from .e2e_metric import E2EMetric 7 | from .cls_metric import ClsMetric 8 | 9 | 10 | class DistillationMetric(object): 11 | def __init__(self, 12 | key=None, 13 | base_metric_name=None, 14 | main_indicator=None, 15 | **kwargs): 16 | self.main_indicator = main_indicator 17 | self.key = key 18 | self.main_indicator = main_indicator 19 | self.base_metric_name = base_metric_name 20 | self.kwargs = kwargs 21 | self.metrics = None 22 | 23 | def _init_metrcis(self, preds): 24 | self.metrics = dict() 25 | mod = importlib.import_module(__name__) 26 | for key in preds: 27 | self.metrics[key] = getattr(mod, self.base_metric_name)( 28 | main_indicator=self.main_indicator, **self.kwargs) 29 | self.metrics[key].reset() 30 | 31 | def __call__(self, preds, batch, **kwargs): 32 | assert isinstance(preds, dict) 33 | if self.metrics is None: 34 | self._init_metrcis(preds) 35 | output = dict() 36 | for key in preds: 37 | self.metrics[key].__call__(preds[key], batch, **kwargs) 38 | 39 | def get_metric(self): 40 | """ 41 | return metrics { 42 | 'acc': 0, 43 | 'norm_edit_dis': 0, 44 | } 45 | """ 46 | output = dict() 47 | for key in self.metrics: 48 | metric = self.metrics[key].get_metric() 49 | # main indicator 50 | if key == self.key: 51 | output.update(metric) 52 | else: 53 | for sub_key in metric: 54 | output["{}_{}".format(key, sub_key)] = metric[sub_key] 55 | return output 56 | 57 | def reset(self): 58 | for key in self.metrics: 59 | self.metrics[key].reset() 60 | -------------------------------------------------------------------------------- /torchocr/modeling/architectures/__init__.py: -------------------------------------------------------------------------------- 1 | import copy 2 | import importlib 3 | 4 | from .base_model import BaseModel 5 | from .distillation_model import DistillationModel 6 | 7 | __all__ = ["build_model", "DistillationModel"] 8 | 9 | 10 | def build_model(config): 11 | config = copy.deepcopy(config) 12 | if not "name" in config: 13 | arch = BaseModel(config) 14 | else: 15 | name = config.pop("name") 16 | mod = importlib.import_module(__name__) 17 | arch = getattr(mod, name)(config) 18 | return arch -------------------------------------------------------------------------------- /torchocr/modeling/architectures/distillation_model.py: -------------------------------------------------------------------------------- 1 | from torch import nn 2 | from .base_model import BaseModel 3 | from torchocr.utils.ckpt import load_pretrained_params 4 | from torchocr.utils.logging import get_logger 5 | 6 | __all__ = ['DistillationModel'] 7 | 8 | 9 | class DistillationModel(nn.Module): 10 | def __init__(self, config): 11 | """ 12 | the module for OCR distillation. 13 | args: 14 | config (dict): the super parameters for module. 15 | """ 16 | super().__init__() 17 | logger = get_logger() 18 | self.model_list = nn.ModuleDict() 19 | for key in config["Models"]: 20 | model_config = config["Models"][key] 21 | freeze_params = False 22 | pretrained = None 23 | if "freeze_params" in model_config: 24 | freeze_params = model_config.pop("freeze_params") 25 | if "pretrained" in model_config: 26 | pretrained = model_config.pop("pretrained") 27 | model = BaseModel(model_config) 28 | if pretrained is not None: 29 | load_pretrained_params(model, pretrained) 30 | logger.info("{}, load pretrained model from {}".format(key, pretrained)) 31 | if freeze_params: 32 | for param in model.parameters(): 33 | param.requires_grad = False 34 | self.model_list.add_module(key, model) 35 | 36 | def forward(self, x, data=None): 37 | result_dict = dict() 38 | for model_name in self.model_list: 39 | result_dict[model_name] = self.model_list[model_name](x, data) 40 | return result_dict 41 | -------------------------------------------------------------------------------- /torchocr/modeling/backbones/__init__.py: -------------------------------------------------------------------------------- 1 | __all__ = ["build_backbone"] 2 | 3 | 4 | def build_backbone(config, model_type): 5 | if model_type == "det" or model_type == "table": 6 | from .det_mobilenet_v3 import MobileNetV3 7 | from .det_resnet_vd import ResNet_vd 8 | from .rec_lcnetv3 import PPLCNetV3 9 | from .rec_hgnet import PPHGNet_small 10 | support_dict = [ 11 | 'MobileNetV3', 'ResNet_vd', 'PPLCNetV3', 'PPHGNet_small' 12 | ] 13 | elif model_type == "rec" or model_type == "cls": 14 | from .rec_mobilenet_v3 import MobileNetV3 15 | from .rec_resnet_vd import ResNet 16 | from .rec_resnet_31 import ResNet31 17 | from .rec_nrtr_mtb import MTB 18 | from .rec_mv1_enhance import MobileNetV1Enhance 19 | from .rec_lcnetv3 import PPLCNetV3 20 | from .rec_hgnet import PPHGNet_small 21 | support_dict = [ 22 | 'MobileNetV1Enhance', 'ResNet31', 'MobileNetV3', 'PPLCNetV3', 'PPHGNet_small', 'ResNet', 'MTB' 23 | ] 24 | else: 25 | raise NotImplementedError 26 | 27 | module_name = config.pop('name') 28 | assert module_name in support_dict, Exception( 29 | "when model typs is {}, backbone only support {}".format(model_type, 30 | support_dict)) 31 | module_class = eval(module_name)(**config) 32 | return module_class 33 | -------------------------------------------------------------------------------- /torchocr/modeling/backbones/rec_nrtr_mtb.py: -------------------------------------------------------------------------------- 1 | import torch 2 | from torch import nn 3 | 4 | 5 | class MTB(nn.Module): 6 | def __init__(self, cnn_num, in_channels): 7 | super(MTB, self).__init__() 8 | self.block = nn.Sequential() 9 | self.out_channels = in_channels 10 | self.cnn_num = cnn_num 11 | if self.cnn_num == 2: 12 | for i in range(self.cnn_num): 13 | self.block.add_module( 14 | 'conv_{}'.format(i), 15 | nn.Conv2d( 16 | in_channels=in_channels 17 | if i == 0 else 32 * (2**(i - 1)), 18 | out_channels=32 * (2**i), 19 | kernel_size=3, 20 | stride=2, 21 | padding=1)) 22 | self.block.add_module('relu_{}'.format(i), nn.ReLU()) 23 | self.block.add_module('bn_{}'.format(i), nn.BatchNorm2d(32 * (2**i))) 24 | 25 | 26 | def forward(self, images): 27 | x = self.block(images) 28 | if self.cnn_num == 2: 29 | # (b, w, h, c) 30 | x = x.permute(0, 3, 2, 1) 31 | x_shape = x.shape 32 | x = torch.reshape(x, (x_shape[0], x_shape[1], x_shape[2] * x_shape[3])) 33 | return x 34 | -------------------------------------------------------------------------------- /torchocr/modeling/common.py: -------------------------------------------------------------------------------- 1 | 2 | import torch 3 | import torch.nn as nn 4 | 5 | class GELU(nn.Module): 6 | def __init__(self, inplace=True): 7 | super(GELU, self).__init__() 8 | self.inplace = inplace 9 | 10 | def forward(self, x): 11 | return torch.nn.functional.gelu(x) 12 | 13 | class Swish(nn.Module): 14 | def __init__(self, inplace=True): 15 | super(Swish, self).__init__() 16 | self.inplace = inplace 17 | 18 | def forward(self, x): 19 | if self.inplace: 20 | x.mul_(torch.sigmoid(x)) 21 | return x 22 | else: 23 | return x*torch.sigmoid(x) 24 | 25 | 26 | class Activation(nn.Module): 27 | def __init__(self, act_type, inplace=True): 28 | super(Activation, self).__init__() 29 | act_type = act_type.lower() 30 | if act_type == 'relu': 31 | self.act = nn.ReLU(inplace=inplace) 32 | elif act_type == 'relu6': 33 | self.act = nn.ReLU6(inplace=inplace) 34 | elif act_type == 'sigmoid': 35 | self.act = nn.Sigmoid() 36 | elif act_type == 'hard_sigmoid': 37 | self.act = nn.Hardsigmoid(inplace) 38 | elif act_type == 'hard_swish': 39 | self.act = nn.Hardswish(inplace=inplace) 40 | elif act_type == 'leakyrelu': 41 | self.act = nn.LeakyReLU(inplace=inplace) 42 | elif act_type == 'gelu': 43 | self.act = GELU(inplace=inplace) 44 | elif act_type == 'swish': 45 | self.act = Swish(inplace=inplace) 46 | else: 47 | raise NotImplementedError 48 | 49 | def forward(self, inputs): 50 | return self.act(inputs) -------------------------------------------------------------------------------- /torchocr/modeling/heads/__init__.py: -------------------------------------------------------------------------------- 1 | __all__ = ['build_head'] 2 | 3 | 4 | def build_head(config): 5 | # det head 6 | from .det_db_head import DBHead, PFHeadLocal 7 | # rec head 8 | from .rec_ctc_head import CTCHead 9 | from .rec_multi_head import MultiHead 10 | from .rec_sar_head import SARHead 11 | from .rec_att_head import AttentionHead 12 | from .rec_nrtr_head import Transformer 13 | # cls head 14 | from .cls_head import ClsHead 15 | 16 | support_dict = [ 17 | 'MultiHead', 'SARHead', 'DBHead', 'CTCHead', 'ClsHead', 'PFHeadLocal', 'AttentionHead', 'Transformer' 18 | ] 19 | 20 | module_name = config.pop('name') 21 | assert module_name in support_dict, Exception('head only support {}'.format( 22 | support_dict)) 23 | module_class = eval(module_name)(**config) 24 | return module_class 25 | -------------------------------------------------------------------------------- /torchocr/modeling/heads/cls_head.py: -------------------------------------------------------------------------------- 1 | import torch 2 | import torch.nn.functional as F 3 | from torch import nn 4 | 5 | 6 | class ClsHead(nn.Module): 7 | """ 8 | Class orientation 9 | 10 | Args: 11 | 12 | params(dict): super parameters for build Class network 13 | """ 14 | 15 | def __init__(self, in_channels, class_dim, **kwargs): 16 | super(ClsHead, self).__init__() 17 | self.pool = nn.AdaptiveAvgPool2d(1) 18 | self.fc = nn.Linear(in_channels, class_dim) 19 | 20 | def forward(self, x, data=None): 21 | x = self.pool(x) 22 | x = torch.reshape(x, shape=[x.shape[0], x.shape[1]]) 23 | x = self.fc(x) 24 | if not self.training: 25 | x = F.softmax(x, dim=1) 26 | return {'res': x} 27 | -------------------------------------------------------------------------------- /torchocr/modeling/heads/rec_ctc_head.py: -------------------------------------------------------------------------------- 1 | import torch.nn as nn 2 | import torch.nn.functional as F 3 | 4 | class CTCHead(nn.Module): 5 | def __init__(self, 6 | in_channels, 7 | out_channels=6625, 8 | mid_channels=None, 9 | return_feats=False, 10 | **kwargs): 11 | super(CTCHead, self).__init__() 12 | if mid_channels is None: 13 | self.fc = nn.Linear( 14 | in_channels, 15 | out_channels, 16 | bias=True,) 17 | else: 18 | self.fc1 = nn.Linear( 19 | in_channels, 20 | mid_channels, 21 | bias=True, 22 | ) 23 | self.fc2 = nn.Linear( 24 | mid_channels, 25 | out_channels, 26 | bias=True, 27 | ) 28 | 29 | self.out_channels = out_channels 30 | self.mid_channels = mid_channels 31 | self.return_feats = return_feats 32 | 33 | 34 | def forward(self, x, data=None): 35 | if self.mid_channels is None: 36 | predicts = self.fc(x) 37 | else: 38 | x = self.fc1(x) 39 | predicts = self.fc2(x) 40 | 41 | result = {'res': predicts} 42 | if self.return_feats: 43 | result['feat'] = x 44 | 45 | if not self.training: 46 | result['res'] = F.softmax(result['res'], dim=2) 47 | return result -------------------------------------------------------------------------------- /torchocr/modeling/necks/__init__.py: -------------------------------------------------------------------------------- 1 | __all__ = ['build_neck'] 2 | 3 | 4 | def build_neck(config): 5 | from .db_fpn import DBFPN, RSEFPN, LKPAN 6 | from .rnn import SequenceEncoder 7 | support_dict = [ 8 | 'SequenceEncoder', 'DBFPN', 'RSEFPN', 'LKPAN' 9 | ] 10 | 11 | module_name = config.pop('name') 12 | assert module_name in support_dict, Exception('neck only support {}'.format( 13 | support_dict)) 14 | 15 | module_class = eval(module_name)(**config) 16 | return module_class 17 | -------------------------------------------------------------------------------- /torchocr/modeling/transforms/__init__.py: -------------------------------------------------------------------------------- 1 | __all__ = ['build_transform'] 2 | 3 | 4 | def build_transform(config): 5 | from .tps import TPS 6 | 7 | support_dict = ['TPS'] 8 | 9 | module_name = config.pop('name') 10 | assert module_name in support_dict, Exception( 11 | 'transform only support {}'.format(support_dict)) 12 | module_class = eval(module_name)(**config) 13 | return module_class 14 | -------------------------------------------------------------------------------- /torchocr/optimizer/__init__.py: -------------------------------------------------------------------------------- 1 | import copy 2 | 3 | import torch 4 | 5 | __all__ = ['build_optimizer'] 6 | 7 | 8 | def build_optimizer(optim_config, lr_scheduler_config, epochs, step_each_epoch, model): 9 | from . import lr 10 | config = copy.deepcopy(optim_config) 11 | train_params = filter(lambda p: p.requires_grad, model.parameters()) 12 | optim = getattr(torch.optim, config.pop('name'))(params=train_params, **config) 13 | 14 | lr_config = copy.deepcopy(lr_scheduler_config) 15 | lr_config.update({'epochs': epochs, 'step_each_epoch': step_each_epoch}) 16 | lr_scheduler = getattr(lr, lr_config.pop('name'))(**lr_config)(optimizer=optim) 17 | return optim, lr_scheduler 18 | -------------------------------------------------------------------------------- /torchocr/postprocess/cls_postprocess.py: -------------------------------------------------------------------------------- 1 | import torch 2 | 3 | 4 | class ClsPostProcess(object): 5 | """ Convert between text-label and text-index """ 6 | 7 | def __init__(self, label_list=None, **kwargs): 8 | super(ClsPostProcess, self).__init__() 9 | self.label_list = label_list 10 | 11 | def __call__(self, preds, batch=None, *args, **kwargs): 12 | if 'res' in preds: 13 | preds = preds['res'] 14 | if isinstance(preds, torch.Tensor): 15 | preds = preds.detach().cpu().numpy() 16 | 17 | label_list = self.label_list 18 | if label_list is None: 19 | label_list = {idx: idx for idx in range(preds.shape[-1])} 20 | 21 | pred_idxs = preds.argmax(axis=1) 22 | decode_out = [(label_list[idx], preds[i, idx]) for i, idx in enumerate(pred_idxs)] 23 | if batch is None: 24 | return decode_out 25 | label = [(label_list[idx], 1.0) for idx in batch[1].cpu().numpy()] 26 | return decode_out, label 27 | -------------------------------------------------------------------------------- /torchocr/postprocess/pg_postprocess.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | 4 | __dir__ = os.path.dirname(__file__) 5 | sys.path.append(__dir__) 6 | sys.path.append(os.path.join(__dir__, '..')) 7 | from torchocr.utils.e2e_utils.pgnet_pp_utils import PGNet_PostProcess 8 | 9 | 10 | class PGPostProcess(object): 11 | """ 12 | The post process for PGNet. 13 | """ 14 | 15 | def __init__(self, 16 | character_dict_path, 17 | valid_set, 18 | score_thresh, 19 | mode, 20 | point_gather_mode=None, 21 | **kwargs): 22 | self.character_dict_path = character_dict_path 23 | self.valid_set = valid_set 24 | self.score_thresh = score_thresh 25 | self.mode = mode 26 | self.point_gather_mode = point_gather_mode 27 | 28 | # c++ la-nms is faster, but only support python 3.5 29 | self.is_python35 = False 30 | if sys.version_info.major == 3 and sys.version_info.minor == 5: 31 | self.is_python35 = True 32 | 33 | def __call__(self, outs_dict, shape_list): 34 | post = PGNet_PostProcess( 35 | self.character_dict_path, 36 | self.valid_set, 37 | self.score_thresh, 38 | outs_dict, 39 | shape_list, 40 | point_gather_mode=self.point_gather_mode) 41 | if self.mode == 'fast': 42 | data = post.pg_postprocess_fast() 43 | else: 44 | data = post.pg_postprocess_slow() 45 | return data 46 | -------------------------------------------------------------------------------- /torchocr/postprocess/pse_postprocess/__init__.py: -------------------------------------------------------------------------------- 1 | from .pse_postprocess import PSEPostProcess -------------------------------------------------------------------------------- /torchocr/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 | -------------------------------------------------------------------------------- /torchocr/postprocess/pse_postprocess/pse/__init__.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import os 3 | import subprocess 4 | 5 | python_path = sys.executable 6 | 7 | ori_path = os.getcwd() 8 | os.chdir('torchocr/postprocess/pse_postprocess/pse') 9 | if subprocess.call( 10 | '{} setup.py build_ext --inplace'.format(python_path), shell=True) != 0: 11 | raise RuntimeError( 12 | '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+'. 13 | format(os.path.dirname(os.path.realpath(__file__)))) 14 | os.chdir(ori_path) 15 | 16 | from .pse import pse 17 | -------------------------------------------------------------------------------- /torchocr/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 | -------------------------------------------------------------------------------- /torchocr/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 | ~ -------------------------------------------------------------------------------- /torchocr/utils/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenmuZhou/PytorchOCR/f899e9ddf953cbbcfb3f269318d0daa5ebcd2b53/torchocr/utils/__init__.py -------------------------------------------------------------------------------- /torchocr/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 | -------------------------------------------------------------------------------- /torchocr/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 | -------------------------------------------------------------------------------- /torchocr/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 | -------------------------------------------------------------------------------- /torchocr/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 | -------------------------------------------------------------------------------- /torchocr/utils/dict/confuse.pkl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenmuZhou/PytorchOCR/f899e9ddf953cbbcfb3f269318d0daa5ebcd2b53/torchocr/utils/dict/confuse.pkl -------------------------------------------------------------------------------- /torchocr/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 | -------------------------------------------------------------------------------- /torchocr/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 | -------------------------------------------------------------------------------- /torchocr/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 | -------------------------------------------------------------------------------- /torchocr/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 | -------------------------------------------------------------------------------- /torchocr/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 | -------------------------------------------------------------------------------- /torchocr/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 | -------------------------------------------------------------------------------- /torchocr/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 | -------------------------------------------------------------------------------- /torchocr/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 | -------------------------------------------------------------------------------- /torchocr/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 | -------------------------------------------------------------------------------- /torchocr/utils/dict/kie_dict/xfund_class_list.txt: -------------------------------------------------------------------------------- 1 | OTHER 2 | QUESTION 3 | ANSWER 4 | HEADER 5 | -------------------------------------------------------------------------------- /torchocr/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 | _ -------------------------------------------------------------------------------- /torchocr/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 | -------------------------------------------------------------------------------- /torchocr/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 -------------------------------------------------------------------------------- /torchocr/utils/dict/layout_dict/layout_publaynet_dict.txt: -------------------------------------------------------------------------------- 1 | text 2 | title 3 | list 4 | table 5 | figure -------------------------------------------------------------------------------- /torchocr/utils/dict/layout_dict/layout_table_dict.txt: -------------------------------------------------------------------------------- 1 | table -------------------------------------------------------------------------------- /torchocr/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 | -------------------------------------------------------------------------------- /torchocr/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 | -------------------------------------------------------------------------------- /torchocr/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 | -------------------------------------------------------------------------------- /torchocr/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 | -------------------------------------------------------------------------------- /torchocr/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 | -------------------------------------------------------------------------------- /torchocr/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 | -------------------------------------------------------------------------------- /torchocr/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 | -------------------------------------------------------------------------------- /torchocr/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 | ^ -------------------------------------------------------------------------------- /torchocr/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 | -------------------------------------------------------------------------------- /torchocr/utils/dict/table_master_structure_dict.txt: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | 13 | colspan="2" 14 | colspan="3" 15 | 16 | 17 | rowspan="2" 18 | colspan="4" 19 | colspan="6" 20 | rowspan="3" 21 | colspan="9" 22 | colspan="10" 23 | colspan="7" 24 | rowspan="4" 25 | rowspan="5" 26 | rowspan="9" 27 | colspan="8" 28 | rowspan="8" 29 | rowspan="6" 30 | rowspan="7" 31 | rowspan="10" 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /torchocr/utils/dict/table_structure_dict.txt: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | colspan="2" 13 | colspan="3" 14 | rowspan="2" 15 | colspan="4" 16 | colspan="6" 17 | rowspan="3" 18 | colspan="9" 19 | colspan="10" 20 | colspan="7" 21 | rowspan="4" 22 | rowspan="5" 23 | rowspan="9" 24 | colspan="8" 25 | rowspan="8" 26 | rowspan="6" 27 | rowspan="7" 28 | rowspan="10" -------------------------------------------------------------------------------- /torchocr/utils/dict/table_structure_dict_ch.txt: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 10 | 11 | colspan="2" 12 | colspan="3" 13 | colspan="4" 14 | colspan="5" 15 | colspan="6" 16 | colspan="7" 17 | colspan="8" 18 | colspan="9" 19 | colspan="10" 20 | colspan="11" 21 | colspan="12" 22 | colspan="13" 23 | colspan="14" 24 | colspan="15" 25 | colspan="16" 26 | colspan="17" 27 | colspan="18" 28 | colspan="19" 29 | colspan="20" 30 | rowspan="2" 31 | rowspan="3" 32 | rowspan="4" 33 | rowspan="5" 34 | rowspan="6" 35 | rowspan="7" 36 | rowspan="8" 37 | rowspan="9" 38 | rowspan="10" 39 | rowspan="11" 40 | rowspan="12" 41 | rowspan="13" 42 | rowspan="14" 43 | rowspan="15" 44 | rowspan="16" 45 | rowspan="17" 46 | rowspan="18" 47 | rowspan="19" 48 | rowspan="20" 49 | -------------------------------------------------------------------------------- /torchocr/utils/dict/te_dict.txt: -------------------------------------------------------------------------------- 1 | t 2 | e 3 | _ 4 | i 5 | m 6 | g 7 | / 8 | 5 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 | 3 22 | 4 23 | 8 24 | 9 25 | . 26 | j 27 | p 28 | త 29 | ె 30 | ర 31 | క 32 | ్ 33 | ి 34 | ం 35 | చ 36 | ే 37 | ద 38 | ు 39 | 7 40 | 6 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 | ఐ 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 | s 112 | c 113 | n 114 | w 115 | k 116 | J 117 | G 118 | u 119 | d 120 | r 121 | E 122 | o 123 | h 124 | y 125 | b 126 | f 127 | B 128 | M 129 | O 130 | T 131 | N 132 | D 133 | P 134 | A 135 | F 136 | x 137 | W 138 | Y 139 | U 140 | H 141 | K 142 | X 143 | z 144 | Z 145 | Q 146 | q 147 | É 148 | % 149 | # 150 | @ 151 | é 152 | -------------------------------------------------------------------------------- /torchocr/utils/dict/ug_dict.txt: -------------------------------------------------------------------------------- 1 | u 2 | g 3 | _ 4 | i 5 | m 6 | / 7 | 1 8 | I 9 | L 10 | S 11 | V 12 | R 13 | C 14 | 2 15 | 0 16 | v 17 | a 18 | l 19 | 8 20 | 5 21 | 3 22 | 6 23 | 9 24 | . 25 | j 26 | p 27 | 28 | ق 29 | ا 30 | پ 31 | ل 32 | 4 33 | 7 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 | s 64 | c 65 | e 66 | n 67 | w 68 | P 69 | E 70 | D 71 | U 72 | d 73 | r 74 | b 75 | y 76 | B 77 | o 78 | O 79 | Y 80 | N 81 | T 82 | k 83 | t 84 | h 85 | A 86 | H 87 | F 88 | z 89 | W 90 | K 91 | G 92 | M 93 | f 94 | Z 95 | X 96 | Q 97 | J 98 | x 99 | q 100 | - 101 | ! 102 | % 103 | # 104 | ? 105 | : 106 | $ 107 | , 108 | & 109 | ' 110 | É 111 | @ 112 | é 113 | ( 114 | + 115 | -------------------------------------------------------------------------------- /torchocr/utils/dict/uk_dict.txt: -------------------------------------------------------------------------------- 1 | u 2 | k 3 | _ 4 | i 5 | m 6 | g 7 | / 8 | 1 9 | 6 10 | I 11 | L 12 | S 13 | V 14 | R 15 | C 16 | 2 17 | 0 18 | v 19 | a 20 | l 21 | 7 22 | 9 23 | . 24 | j 25 | p 26 | в 27 | і 28 | д 29 | п 30 | о 31 | н 32 | с 33 | т 34 | ю 35 | 4 36 | 5 37 | 3 38 | а 39 | и 40 | м 41 | е 42 | р 43 | ч 44 | у 45 | Б 46 | з 47 | л 48 | к 49 | 8 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 | s 92 | c 93 | e 94 | n 95 | w 96 | A 97 | P 98 | r 99 | E 100 | t 101 | o 102 | h 103 | d 104 | y 105 | M 106 | G 107 | N 108 | F 109 | B 110 | T 111 | D 112 | U 113 | O 114 | W 115 | Z 116 | f 117 | H 118 | Y 119 | b 120 | K 121 | z 122 | x 123 | Q 124 | X 125 | q 126 | J 127 | $ 128 | - 129 | ' 130 | # 131 | & 132 | % 133 | ? 134 | : 135 | ! 136 | , 137 | + 138 | @ 139 | ( 140 | é 141 | É 142 | 143 | -------------------------------------------------------------------------------- /torchocr/utils/dict/ur_dict.txt: -------------------------------------------------------------------------------- 1 | u 2 | r 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 | a 20 | l 21 | 9 22 | 7 23 | 8 24 | . 25 | j 26 | p 27 | 28 | چ 29 | ٹ 30 | پ 31 | ا 32 | ئ 33 | ی 34 | ے 35 | 4 36 | 6 37 | و 38 | ل 39 | ن 40 | ڈ 41 | ھ 42 | ک 43 | ت 44 | ش 45 | ف 46 | ق 47 | ر 48 | د 49 | 5 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 | s 88 | c 89 | e 90 | n 91 | w 92 | o 93 | d 94 | t 95 | D 96 | M 97 | T 98 | U 99 | E 100 | b 101 | P 102 | h 103 | y 104 | W 105 | H 106 | A 107 | x 108 | B 109 | O 110 | N 111 | G 112 | Y 113 | Q 114 | F 115 | k 116 | K 117 | q 118 | J 119 | Z 120 | f 121 | z 122 | X 123 | ' 124 | @ 125 | & 126 | ! 127 | , 128 | : 129 | $ 130 | - 131 | # 132 | ? 133 | % 134 | é 135 | + 136 | ( 137 | É 138 | -------------------------------------------------------------------------------- /torchocr/utils/dict/xi_dict.txt: -------------------------------------------------------------------------------- 1 | x 2 | i 3 | _ 4 | m 5 | g 6 | / 7 | 1 8 | 0 9 | I 10 | L 11 | S 12 | V 13 | R 14 | C 15 | 2 16 | v 17 | a 18 | l 19 | 3 20 | 6 21 | 4 22 | 5 23 | . 24 | j 25 | p 26 | 27 | Q 28 | u 29 | e 30 | r 31 | o 32 | 8 33 | 7 34 | n 35 | c 36 | 9 37 | t 38 | b 39 | é 40 | q 41 | d 42 | ó 43 | y 44 | F 45 | s 46 | , 47 | O 48 | í 49 | T 50 | f 51 | " 52 | U 53 | M 54 | h 55 | : 56 | P 57 | H 58 | A 59 | E 60 | D 61 | z 62 | N 63 | á 64 | ñ 65 | ú 66 | % 67 | ; 68 | è 69 | + 70 | Y 71 | - 72 | B 73 | G 74 | ( 75 | ) 76 | ¿ 77 | ? 78 | w 79 | ¡ 80 | ! 81 | X 82 | É 83 | K 84 | k 85 | Á 86 | ü 87 | Ú 88 | « 89 | » 90 | J 91 | ' 92 | ö 93 | W 94 | Z 95 | º 96 | Ö 97 | ­ 98 | [ 99 | ] 100 | Ç 101 | ç 102 | à 103 | ä 104 | û 105 | ò 106 | Í 107 | ê 108 | ô 109 | ø 110 | ª 111 | -------------------------------------------------------------------------------- /torchocr/utils/dict90.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 | ~ -------------------------------------------------------------------------------- /torchocr/utils/en_dict.txt: -------------------------------------------------------------------------------- 1 | 0 2 | 1 3 | 2 4 | 3 5 | 4 6 | 5 7 | 6 8 | 7 9 | 8 10 | 9 11 | : 12 | ; 13 | < 14 | = 15 | > 16 | ? 17 | @ 18 | A 19 | B 20 | C 21 | D 22 | E 23 | F 24 | G 25 | H 26 | I 27 | J 28 | K 29 | L 30 | M 31 | N 32 | O 33 | P 34 | Q 35 | R 36 | S 37 | T 38 | U 39 | V 40 | W 41 | X 42 | Y 43 | Z 44 | [ 45 | \ 46 | ] 47 | ^ 48 | _ 49 | ` 50 | a 51 | b 52 | c 53 | d 54 | e 55 | f 56 | g 57 | h 58 | i 59 | j 60 | k 61 | l 62 | m 63 | n 64 | o 65 | p 66 | q 67 | r 68 | s 69 | t 70 | u 71 | v 72 | w 73 | x 74 | y 75 | z 76 | { 77 | | 78 | } 79 | ~ 80 | ! 81 | " 82 | # 83 | $ 84 | % 85 | & 86 | ' 87 | ( 88 | ) 89 | * 90 | + 91 | , 92 | - 93 | . 94 | / 95 | 96 | -------------------------------------------------------------------------------- /torchocr/utils/ic15_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 -------------------------------------------------------------------------------- /torchocr/utils/stats.py: -------------------------------------------------------------------------------- 1 | 2 | import collections 3 | import numpy as np 4 | import datetime 5 | 6 | __all__ = ['TrainingStats', 'Time'] 7 | 8 | 9 | class SmoothedValue(object): 10 | """Track a series of values and provide access to smoothed values over a 11 | window or the global series average. 12 | """ 13 | 14 | def __init__(self, window_size): 15 | self.deque = collections.deque(maxlen=window_size) 16 | 17 | def add_value(self, value): 18 | self.deque.append(value) 19 | 20 | def get_median_value(self): 21 | return np.median(self.deque) 22 | 23 | 24 | def Time(): 25 | return datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S.%f') 26 | 27 | 28 | class TrainingStats(object): 29 | def __init__(self, window_size, stats_keys): 30 | self.window_size = window_size 31 | self.smoothed_losses_and_metrics = { 32 | key: SmoothedValue(window_size) 33 | for key in stats_keys 34 | } 35 | 36 | def update(self, stats): 37 | for k, v in stats.items(): 38 | if k not in self.smoothed_losses_and_metrics: 39 | self.smoothed_losses_and_metrics[k] = SmoothedValue( 40 | self.window_size) 41 | self.smoothed_losses_and_metrics[k].add_value(v) 42 | 43 | def get(self, extras=None): 44 | stats = collections.OrderedDict() 45 | if extras: 46 | for k, v in extras.items(): 47 | stats[k] = v 48 | for k, v in self.smoothed_losses_and_metrics.items(): 49 | stats[k] = round(v.get_median_value(), 6) 50 | 51 | return stats 52 | 53 | def log(self, extras=None): 54 | d = self.get(extras) 55 | strs = [] 56 | for k, v in d.items(): 57 | strs.append('{}: {:x<6f}'.format(k, v)) 58 | strs = ', '.join(strs) 59 | return strs 60 | --------------------------------------------------------------------------------