ソースを参照

refactor: rename files and update import paths for consistency

myhloli 1 ヶ月 前
コミット
499e877165
67 ファイル変更15 行追加6 行削除
  1. 11 3
      mineru/model/mfr/pp_formulanet_plus_m/predict_formula.py
  2. 3 3
      mineru/model/ocr/paddleocr2pytorch/pytorch_paddle.py
  3. 0 0
      mineru/model/utils/__init__.py
  4. 0 0
      mineru/model/utils/pytorchocr/__init__.py
  5. 0 0
      mineru/model/utils/pytorchocr/base_ocr_v20.py
  6. 0 0
      mineru/model/utils/pytorchocr/data/__init__.py
  7. 0 0
      mineru/model/utils/pytorchocr/data/imaug/__init__.py
  8. 0 0
      mineru/model/utils/pytorchocr/data/imaug/operators.py
  9. 0 0
      mineru/model/utils/pytorchocr/modeling/__init__.py
  10. 0 0
      mineru/model/utils/pytorchocr/modeling/architectures/__init__.py
  11. 0 0
      mineru/model/utils/pytorchocr/modeling/architectures/base_model.py
  12. 0 0
      mineru/model/utils/pytorchocr/modeling/backbones/__init__.py
  13. 0 0
      mineru/model/utils/pytorchocr/modeling/backbones/det_mobilenet_v3.py
  14. 0 0
      mineru/model/utils/pytorchocr/modeling/backbones/rec_donut_swin.py
  15. 0 0
      mineru/model/utils/pytorchocr/modeling/backbones/rec_hgnet.py
  16. 0 0
      mineru/model/utils/pytorchocr/modeling/backbones/rec_lcnetv3.py
  17. 0 0
      mineru/model/utils/pytorchocr/modeling/backbones/rec_mobilenet_v3.py
  18. 0 0
      mineru/model/utils/pytorchocr/modeling/backbones/rec_mv1_enhance.py
  19. 0 0
      mineru/model/utils/pytorchocr/modeling/backbones/rec_pphgnetv2.py
  20. 0 0
      mineru/model/utils/pytorchocr/modeling/backbones/rec_svtrnet.py
  21. 0 0
      mineru/model/utils/pytorchocr/modeling/common.py
  22. 0 0
      mineru/model/utils/pytorchocr/modeling/heads/__init__.py
  23. 0 0
      mineru/model/utils/pytorchocr/modeling/heads/cls_head.py
  24. 0 0
      mineru/model/utils/pytorchocr/modeling/heads/det_db_head.py
  25. 0 0
      mineru/model/utils/pytorchocr/modeling/heads/rec_ctc_head.py
  26. 0 0
      mineru/model/utils/pytorchocr/modeling/heads/rec_multi_head.py
  27. 0 0
      mineru/model/utils/pytorchocr/modeling/heads/rec_ppformulanet_head.py
  28. 0 0
      mineru/model/utils/pytorchocr/modeling/heads/rec_unimernet_head.py
  29. 0 0
      mineru/model/utils/pytorchocr/modeling/necks/__init__.py
  30. 0 0
      mineru/model/utils/pytorchocr/modeling/necks/db_fpn.py
  31. 0 0
      mineru/model/utils/pytorchocr/modeling/necks/intracl.py
  32. 0 0
      mineru/model/utils/pytorchocr/modeling/necks/rnn.py
  33. 0 0
      mineru/model/utils/pytorchocr/postprocess/__init__.py
  34. 0 0
      mineru/model/utils/pytorchocr/postprocess/cls_postprocess.py
  35. 0 0
      mineru/model/utils/pytorchocr/postprocess/db_postprocess.py
  36. 0 0
      mineru/model/utils/pytorchocr/postprocess/rec_postprocess.py
  37. 0 0
      mineru/model/utils/pytorchocr/utils/__init__.py
  38. 0 0
      mineru/model/utils/pytorchocr/utils/resources/arch_config.yaml
  39. 0 0
      mineru/model/utils/pytorchocr/utils/resources/dict/arabic_dict.txt
  40. 0 0
      mineru/model/utils/pytorchocr/utils/resources/dict/chinese_cht_dict.txt
  41. 0 0
      mineru/model/utils/pytorchocr/utils/resources/dict/cyrillic_dict.txt
  42. 0 0
      mineru/model/utils/pytorchocr/utils/resources/dict/devanagari_dict.txt
  43. 0 0
      mineru/model/utils/pytorchocr/utils/resources/dict/en_dict.txt
  44. 0 0
      mineru/model/utils/pytorchocr/utils/resources/dict/japan_dict.txt
  45. 0 0
      mineru/model/utils/pytorchocr/utils/resources/dict/ka_dict.txt
  46. 0 0
      mineru/model/utils/pytorchocr/utils/resources/dict/korean_dict.txt
  47. 0 0
      mineru/model/utils/pytorchocr/utils/resources/dict/latin_dict.txt
  48. 0 0
      mineru/model/utils/pytorchocr/utils/resources/dict/ppocr_keys_v1.txt
  49. 0 0
      mineru/model/utils/pytorchocr/utils/resources/dict/ppocrv4_doc_dict.txt
  50. 0 0
      mineru/model/utils/pytorchocr/utils/resources/dict/ppocrv5_dict.txt
  51. 0 0
      mineru/model/utils/pytorchocr/utils/resources/dict/ppocrv5_el_dict.txt
  52. 0 0
      mineru/model/utils/pytorchocr/utils/resources/dict/ppocrv5_en_dict.txt
  53. 0 0
      mineru/model/utils/pytorchocr/utils/resources/dict/ppocrv5_eslav_dict.txt
  54. 0 0
      mineru/model/utils/pytorchocr/utils/resources/dict/ppocrv5_korean_dict.txt
  55. 0 0
      mineru/model/utils/pytorchocr/utils/resources/dict/ppocrv5_latin_dict.txt
  56. 0 0
      mineru/model/utils/pytorchocr/utils/resources/dict/ppocrv5_th_dict.txt
  57. 0 0
      mineru/model/utils/pytorchocr/utils/resources/dict/ta_dict.txt
  58. 0 0
      mineru/model/utils/pytorchocr/utils/resources/dict/te_dict.txt
  59. 0 0
      mineru/model/utils/pytorchocr/utils/resources/models_config.yml
  60. 0 0
      mineru/model/utils/pytorchocr/utils/resources/pp_formulanet_arch_config.yaml
  61. 0 0
      mineru/model/utils/tools/__init__.py
  62. 1 0
      mineru/model/utils/tools/infer/__init__.py
  63. 0 0
      mineru/model/utils/tools/infer/predict_cls.py
  64. 0 0
      mineru/model/utils/tools/infer/predict_det.py
  65. 0 0
      mineru/model/utils/tools/infer/predict_rec.py
  66. 0 0
      mineru/model/utils/tools/infer/predict_system.py
  67. 0 0
      mineru/model/utils/tools/infer/pytorchocr_utility.py

+ 11 - 3
mineru/model/mfr/pp_formulanet_plus_m/predict_formula.py

@@ -3,8 +3,8 @@ import torch
 import yaml
 from pathlib import Path
 from tqdm import tqdm
-from mineru.model.ocr.paddleocr2pytorch.tools.infer import pytorchocr_utility
-from mineru.model.ocr.paddleocr2pytorch.pytorchocr.base_ocr_v20 import BaseOCRV20
+from mineru.model.utils.tools.infer import pytorchocr_utility
+from mineru.model.utils.pytorchocr.base_ocr_v20 import BaseOCRV20
 from .processors import (
     UniMERNetImgDecode,
     UniMERNetTestTransform,
@@ -24,7 +24,14 @@ class FormulaRecognizer(BaseOCRV20):
             weight_dir,
             "PP-FormulaNet_plus-M.pth",
         )
-        self.yaml_path = Path(__file__).parent / "config" / "arch_config.yaml"
+        self.yaml_path = os.path.join(
+            Path(__file__).parent.parent.parent,
+            "utils",
+            "pytorchocr",
+            "utils",
+            "resources",
+            "pp_formulanet_arch_config.yaml"
+        )
         self.infer_yaml_path = os.path.join(
             weight_dir,
             "PP-FormulaNet_plus-M_inference.yml",
@@ -38,6 +45,7 @@ class FormulaRecognizer(BaseOCRV20):
         super(FormulaRecognizer, self).__init__(network_config)
 
         self.load_state_dict(weights)
+        # device = "cpu"
         self.device = torch.device(device) if isinstance(device, str) else device
         self.net.to(self.device)
         self.net.eval()

+ 3 - 3
mineru/model/ocr/paddleocr2pytorch/pytorch_paddle.py

@@ -13,8 +13,8 @@ from mineru.utils.config_reader import get_device
 from mineru.utils.enum_class import ModelPath
 from mineru.utils.models_download_utils import auto_download_and_get_model_root_path
 from mineru.utils.ocr_utils import check_img, preprocess_image, sorted_boxes, merge_det_boxes, update_det_boxes, get_rotate_crop_image
-from mineru.model.ocr.paddleocr2pytorch.tools.infer.predict_system import TextSystem
-from mineru.model.ocr.paddleocr2pytorch.tools.infer import pytorchocr_utility as utility
+from mineru.model.utils.tools.infer.predict_system import TextSystem
+from mineru.model.utils.tools.infer import pytorchocr_utility as utility
 import argparse
 
 
@@ -47,7 +47,7 @@ def get_model_params(lang, config):
         raise Exception (f'Language {lang} not supported')
 
 
-root_dir = Path(__file__).resolve().parent
+root_dir = os.path.join(Path(__file__).resolve().parent.parent.parent, 'utils')
 
 
 class PytorchPaddleOCR(TextSystem):

+ 0 - 0
mineru/model/ocr/paddleocr2pytorch/tools/infer/__init__.py → mineru/model/utils/__init__.py


+ 0 - 0
mineru/model/ocr/paddleocr2pytorch/pytorchocr/__init__.py → mineru/model/utils/pytorchocr/__init__.py


+ 0 - 0
mineru/model/ocr/paddleocr2pytorch/pytorchocr/base_ocr_v20.py → mineru/model/utils/pytorchocr/base_ocr_v20.py


+ 0 - 0
mineru/model/ocr/paddleocr2pytorch/pytorchocr/data/__init__.py → mineru/model/utils/pytorchocr/data/__init__.py


+ 0 - 0
mineru/model/ocr/paddleocr2pytorch/pytorchocr/data/imaug/__init__.py → mineru/model/utils/pytorchocr/data/imaug/__init__.py


+ 0 - 0
mineru/model/ocr/paddleocr2pytorch/pytorchocr/data/imaug/operators.py → mineru/model/utils/pytorchocr/data/imaug/operators.py


+ 0 - 0
mineru/model/ocr/paddleocr2pytorch/pytorchocr/modeling/__init__.py → mineru/model/utils/pytorchocr/modeling/__init__.py


+ 0 - 0
mineru/model/ocr/paddleocr2pytorch/pytorchocr/modeling/architectures/__init__.py → mineru/model/utils/pytorchocr/modeling/architectures/__init__.py


+ 0 - 0
mineru/model/ocr/paddleocr2pytorch/pytorchocr/modeling/architectures/base_model.py → mineru/model/utils/pytorchocr/modeling/architectures/base_model.py


+ 0 - 0
mineru/model/ocr/paddleocr2pytorch/pytorchocr/modeling/backbones/__init__.py → mineru/model/utils/pytorchocr/modeling/backbones/__init__.py


+ 0 - 0
mineru/model/ocr/paddleocr2pytorch/pytorchocr/modeling/backbones/det_mobilenet_v3.py → mineru/model/utils/pytorchocr/modeling/backbones/det_mobilenet_v3.py


+ 0 - 0
mineru/model/ocr/paddleocr2pytorch/pytorchocr/modeling/backbones/rec_donut_swin.py → mineru/model/utils/pytorchocr/modeling/backbones/rec_donut_swin.py


+ 0 - 0
mineru/model/ocr/paddleocr2pytorch/pytorchocr/modeling/backbones/rec_hgnet.py → mineru/model/utils/pytorchocr/modeling/backbones/rec_hgnet.py


+ 0 - 0
mineru/model/ocr/paddleocr2pytorch/pytorchocr/modeling/backbones/rec_lcnetv3.py → mineru/model/utils/pytorchocr/modeling/backbones/rec_lcnetv3.py


+ 0 - 0
mineru/model/ocr/paddleocr2pytorch/pytorchocr/modeling/backbones/rec_mobilenet_v3.py → mineru/model/utils/pytorchocr/modeling/backbones/rec_mobilenet_v3.py


+ 0 - 0
mineru/model/ocr/paddleocr2pytorch/pytorchocr/modeling/backbones/rec_mv1_enhance.py → mineru/model/utils/pytorchocr/modeling/backbones/rec_mv1_enhance.py


+ 0 - 0
mineru/model/ocr/paddleocr2pytorch/pytorchocr/modeling/backbones/rec_pphgnetv2.py → mineru/model/utils/pytorchocr/modeling/backbones/rec_pphgnetv2.py


+ 0 - 0
mineru/model/ocr/paddleocr2pytorch/pytorchocr/modeling/backbones/rec_svtrnet.py → mineru/model/utils/pytorchocr/modeling/backbones/rec_svtrnet.py


+ 0 - 0
mineru/model/ocr/paddleocr2pytorch/pytorchocr/modeling/common.py → mineru/model/utils/pytorchocr/modeling/common.py


+ 0 - 0
mineru/model/ocr/paddleocr2pytorch/pytorchocr/modeling/heads/__init__.py → mineru/model/utils/pytorchocr/modeling/heads/__init__.py


+ 0 - 0
mineru/model/ocr/paddleocr2pytorch/pytorchocr/modeling/heads/cls_head.py → mineru/model/utils/pytorchocr/modeling/heads/cls_head.py


+ 0 - 0
mineru/model/ocr/paddleocr2pytorch/pytorchocr/modeling/heads/det_db_head.py → mineru/model/utils/pytorchocr/modeling/heads/det_db_head.py


+ 0 - 0
mineru/model/ocr/paddleocr2pytorch/pytorchocr/modeling/heads/rec_ctc_head.py → mineru/model/utils/pytorchocr/modeling/heads/rec_ctc_head.py


+ 0 - 0
mineru/model/ocr/paddleocr2pytorch/pytorchocr/modeling/heads/rec_multi_head.py → mineru/model/utils/pytorchocr/modeling/heads/rec_multi_head.py


+ 0 - 0
mineru/model/ocr/paddleocr2pytorch/pytorchocr/modeling/heads/rec_ppformulanet_head.py → mineru/model/utils/pytorchocr/modeling/heads/rec_ppformulanet_head.py


+ 0 - 0
mineru/model/ocr/paddleocr2pytorch/pytorchocr/modeling/heads/rec_unimernet_head.py → mineru/model/utils/pytorchocr/modeling/heads/rec_unimernet_head.py


+ 0 - 0
mineru/model/ocr/paddleocr2pytorch/pytorchocr/modeling/necks/__init__.py → mineru/model/utils/pytorchocr/modeling/necks/__init__.py


+ 0 - 0
mineru/model/ocr/paddleocr2pytorch/pytorchocr/modeling/necks/db_fpn.py → mineru/model/utils/pytorchocr/modeling/necks/db_fpn.py


+ 0 - 0
mineru/model/ocr/paddleocr2pytorch/pytorchocr/modeling/necks/intracl.py → mineru/model/utils/pytorchocr/modeling/necks/intracl.py


+ 0 - 0
mineru/model/ocr/paddleocr2pytorch/pytorchocr/modeling/necks/rnn.py → mineru/model/utils/pytorchocr/modeling/necks/rnn.py


+ 0 - 0
mineru/model/ocr/paddleocr2pytorch/pytorchocr/postprocess/__init__.py → mineru/model/utils/pytorchocr/postprocess/__init__.py


+ 0 - 0
mineru/model/ocr/paddleocr2pytorch/pytorchocr/postprocess/cls_postprocess.py → mineru/model/utils/pytorchocr/postprocess/cls_postprocess.py


+ 0 - 0
mineru/model/ocr/paddleocr2pytorch/pytorchocr/postprocess/db_postprocess.py → mineru/model/utils/pytorchocr/postprocess/db_postprocess.py


+ 0 - 0
mineru/model/ocr/paddleocr2pytorch/pytorchocr/postprocess/rec_postprocess.py → mineru/model/utils/pytorchocr/postprocess/rec_postprocess.py


+ 0 - 0
mineru/model/ocr/paddleocr2pytorch/pytorchocr/utils/__init__.py → mineru/model/utils/pytorchocr/utils/__init__.py


+ 0 - 0
mineru/model/ocr/paddleocr2pytorch/pytorchocr/utils/resources/arch_config.yaml → mineru/model/utils/pytorchocr/utils/resources/arch_config.yaml


+ 0 - 0
mineru/model/ocr/paddleocr2pytorch/pytorchocr/utils/resources/dict/arabic_dict.txt → mineru/model/utils/pytorchocr/utils/resources/dict/arabic_dict.txt


+ 0 - 0
mineru/model/ocr/paddleocr2pytorch/pytorchocr/utils/resources/dict/chinese_cht_dict.txt → mineru/model/utils/pytorchocr/utils/resources/dict/chinese_cht_dict.txt


+ 0 - 0
mineru/model/ocr/paddleocr2pytorch/pytorchocr/utils/resources/dict/cyrillic_dict.txt → mineru/model/utils/pytorchocr/utils/resources/dict/cyrillic_dict.txt


+ 0 - 0
mineru/model/ocr/paddleocr2pytorch/pytorchocr/utils/resources/dict/devanagari_dict.txt → mineru/model/utils/pytorchocr/utils/resources/dict/devanagari_dict.txt


+ 0 - 0
mineru/model/ocr/paddleocr2pytorch/pytorchocr/utils/resources/dict/en_dict.txt → mineru/model/utils/pytorchocr/utils/resources/dict/en_dict.txt


+ 0 - 0
mineru/model/ocr/paddleocr2pytorch/pytorchocr/utils/resources/dict/japan_dict.txt → mineru/model/utils/pytorchocr/utils/resources/dict/japan_dict.txt


+ 0 - 0
mineru/model/ocr/paddleocr2pytorch/pytorchocr/utils/resources/dict/ka_dict.txt → mineru/model/utils/pytorchocr/utils/resources/dict/ka_dict.txt


+ 0 - 0
mineru/model/ocr/paddleocr2pytorch/pytorchocr/utils/resources/dict/korean_dict.txt → mineru/model/utils/pytorchocr/utils/resources/dict/korean_dict.txt


+ 0 - 0
mineru/model/ocr/paddleocr2pytorch/pytorchocr/utils/resources/dict/latin_dict.txt → mineru/model/utils/pytorchocr/utils/resources/dict/latin_dict.txt


+ 0 - 0
mineru/model/ocr/paddleocr2pytorch/pytorchocr/utils/resources/dict/ppocr_keys_v1.txt → mineru/model/utils/pytorchocr/utils/resources/dict/ppocr_keys_v1.txt


+ 0 - 0
mineru/model/ocr/paddleocr2pytorch/pytorchocr/utils/resources/dict/ppocrv4_doc_dict.txt → mineru/model/utils/pytorchocr/utils/resources/dict/ppocrv4_doc_dict.txt


+ 0 - 0
mineru/model/ocr/paddleocr2pytorch/pytorchocr/utils/resources/dict/ppocrv5_dict.txt → mineru/model/utils/pytorchocr/utils/resources/dict/ppocrv5_dict.txt


+ 0 - 0
mineru/model/ocr/paddleocr2pytorch/pytorchocr/utils/resources/dict/ppocrv5_el_dict.txt → mineru/model/utils/pytorchocr/utils/resources/dict/ppocrv5_el_dict.txt


+ 0 - 0
mineru/model/ocr/paddleocr2pytorch/pytorchocr/utils/resources/dict/ppocrv5_en_dict.txt → mineru/model/utils/pytorchocr/utils/resources/dict/ppocrv5_en_dict.txt


+ 0 - 0
mineru/model/ocr/paddleocr2pytorch/pytorchocr/utils/resources/dict/ppocrv5_eslav_dict.txt → mineru/model/utils/pytorchocr/utils/resources/dict/ppocrv5_eslav_dict.txt


+ 0 - 0
mineru/model/ocr/paddleocr2pytorch/pytorchocr/utils/resources/dict/ppocrv5_korean_dict.txt → mineru/model/utils/pytorchocr/utils/resources/dict/ppocrv5_korean_dict.txt


+ 0 - 0
mineru/model/ocr/paddleocr2pytorch/pytorchocr/utils/resources/dict/ppocrv5_latin_dict.txt → mineru/model/utils/pytorchocr/utils/resources/dict/ppocrv5_latin_dict.txt


+ 0 - 0
mineru/model/ocr/paddleocr2pytorch/pytorchocr/utils/resources/dict/ppocrv5_th_dict.txt → mineru/model/utils/pytorchocr/utils/resources/dict/ppocrv5_th_dict.txt


+ 0 - 0
mineru/model/ocr/paddleocr2pytorch/pytorchocr/utils/resources/dict/ta_dict.txt → mineru/model/utils/pytorchocr/utils/resources/dict/ta_dict.txt


+ 0 - 0
mineru/model/ocr/paddleocr2pytorch/pytorchocr/utils/resources/dict/te_dict.txt → mineru/model/utils/pytorchocr/utils/resources/dict/te_dict.txt


+ 0 - 0
mineru/model/ocr/paddleocr2pytorch/pytorchocr/utils/resources/models_config.yml → mineru/model/utils/pytorchocr/utils/resources/models_config.yml


+ 0 - 0
mineru/model/mfr/pp_formulanet_plus_m/config/arch_config.yaml → mineru/model/utils/pytorchocr/utils/resources/pp_formulanet_arch_config.yaml


+ 0 - 0
mineru/model/ocr/paddleocr2pytorch/tools/__init__.py → mineru/model/utils/tools/__init__.py


+ 1 - 0
mineru/model/utils/tools/infer/__init__.py

@@ -0,0 +1 @@
+# Copyright (c) Opendatalab. All rights reserved.

+ 0 - 0
mineru/model/ocr/paddleocr2pytorch/tools/infer/predict_cls.py → mineru/model/utils/tools/infer/predict_cls.py


+ 0 - 0
mineru/model/ocr/paddleocr2pytorch/tools/infer/predict_det.py → mineru/model/utils/tools/infer/predict_det.py


+ 0 - 0
mineru/model/ocr/paddleocr2pytorch/tools/infer/predict_rec.py → mineru/model/utils/tools/infer/predict_rec.py


+ 0 - 0
mineru/model/ocr/paddleocr2pytorch/tools/infer/predict_system.py → mineru/model/utils/tools/infer/predict_system.py


+ 0 - 0
mineru/model/ocr/paddleocr2pytorch/tools/infer/pytorchocr_utility.py → mineru/model/utils/tools/infer/pytorchocr_utility.py