xujiayue 2 년 전
부모
커밋
1816b49245
2개의 변경된 파일9개의 추가작업 그리고 9개의 파일을 삭제
  1. 2 2
      blfe_core/ocr.py
  2. 7 7
      blfe_core/parser.py

+ 2 - 2
blfe_core/ocr.py

@@ -71,9 +71,9 @@ class BusinessLicenseOcr:
         conf = line_parser.confidence
 
         if image_type == 0:
-            parser = BusinessLicenseParser0(line_result, image, result)
+            parser = BusinessLicenseParser0(line_result, image, result, self.ocr)
         if image_type == 1:
-            parser = BusinessLicenseParser1(line_result, image, result)
+            parser = BusinessLicenseParser1(line_result, image, result, self.ocr)
 
         ocr_res = parser.parse()
 

+ 7 - 7
blfe_core/parser.py

@@ -45,10 +45,11 @@ class RecItem:
 
 
 class Parser(object):
-    def __init__(self, ocr_results: List[List[OcrResult]], raw_results: List):
+    def __init__(self, ocr_results: List[List[OcrResult]], raw_results: List, ppocr):
         self.result = ocr_results
         self.res = defaultdict(RecItem)
         self.raw_results = raw_results
+        self.ppocr = ppocr
         self.keys = ["social_code", "company_name", "legal_person", "registered_capital", 'type', 'start_date',
                      "business_scope", 'expire_date', 'address', 'stamp']
 
@@ -81,10 +82,9 @@ class Parser(object):
 
 class BusinessLicenseParser0(Parser):
 
-    def __init__(self, ocr_results: List[List[OcrResult]], image, raw_results: List):
-        Parser.__init__(self, ocr_results, raw_results)
+    def __init__(self, ocr_results: List[List[OcrResult]], image, raw_results: List, ppocr):
+        Parser.__init__(self, ocr_results, raw_results, ppocr)
         self.image = image
-        self.ocr = ocr
 
     def social_code(self):
         """
@@ -254,7 +254,7 @@ class BusinessLicenseParser0(Parser):
         经营范围
         """
         ocr = PaddleOCR(use_gpu=True)
-        bs_txt, bs_conf, ad_txt, ad_conf = BussinessParse0(ocr).detection(self.image, self.raw_results)
+        bs_txt, bs_conf, ad_txt, ad_conf = BussinessParse0(self.ocr).detection(self.image, self.raw_results)
         if bool(bs_txt):
             self.res['business_scope'] = RecItem(bs_txt, bs_conf)
 
@@ -346,8 +346,8 @@ class BusinessLicenseParser0(Parser):
 
 class BusinessLicenseParser1(Parser):
 
-    def __init__(self, ocr_results: List[List[OcrResult]], image, raw_results: List):
-        Parser.__init__(self, ocr_results, raw_results)
+    def __init__(self, ocr_results: List[List[OcrResult]], image, raw_results: List, ppocr):
+        Parser.__init__(self, ocr_results, raw_results, ppocr)
         self.image = image
         self.ocr = PaddleOCR(use_gpu=True)