yan chuanli %!s(int64=2) %!d(string=hai) anos
pai
achega
442957d8f6
Modificáronse 4 ficheiros con 29 adicións e 7 borrados
  1. 4 1
      HR_OCR/to_md/new.py
  2. 4 3
      HR_OCR/to_md/ocr_config.py
  3. 5 2
      HR_OCR/to_md/use.py
  4. 16 1
      HR_OCR/tools/convert_json.py

+ 4 - 1
HR_OCR/to_md/new.py

@@ -129,7 +129,10 @@ class Dataset(object):
             else:
                 self.image_list.append(Image(p, None, rotate))
 
-        self.field = Filed.get(field)
+        if ocr_name == 'regbook':
+            self.field = Filed.get(field + str(image_type))
+        else:
+            self.field = Filed.get(field)
 
         self.correct = {k: 0 for k in self.field}
         self.error = {k: 0 for k in self.field}

+ 4 - 3
HR_OCR/to_md/ocr_config.py

@@ -97,10 +97,10 @@ OCR_CONFIGS = {
 
 # 字段
 cet_field = ['orientation', 'name', 'id', 'language', 'level', 'exam_time', 'score']
-regbook_field = ['orientation', 'type', 'address', 'address_province', 'address_city', 'address_region',
-                 'address_detail', 'name', 'id', 'gender', 'birthplace', 'birthplace_province', 'birthplace_city',
+regbook_0_field = ['orientation', 'name', 'id', 'gender', 'birthplace', 'birthplace_province', 'birthplace_city',
                  'birthplace_region', 'native_place', 'native_place_province', 'native_place_city',
                  'native_place_region', 'blood_type', 'religion']
+regbook_1_field = ['orientation', 'type', 'address', 'address_province', 'address_city', 'address_region', 'address_detail']
 
 business_license = ['orientation', 'social_code', 'company_name', 'legal_person', 'registered_capital', 'type',
                     'start_date', 'business_scope', 'expire_date', 'address', 'stamp']
@@ -108,6 +108,7 @@ business_license = ['orientation', 'social_code', 'company_name', 'legal_person'
 #                     'start_date', 'business_scope', 'expire_date', 'address']
 Filed = {
     'cet': cet_field,
-    'regbook': regbook_field,
+    'regbook0': regbook_0_field,
+    'regbook1': regbook_1_field,
     'business_license': business_license
 }

+ 5 - 2
HR_OCR/to_md/use.py

@@ -14,7 +14,8 @@ from new import MD, Image, Dataset, parser_path
 
 # config
 # 图片路径
-image_path = Path('/Users/zeke/work/sx/OCR/image_data/RE_1012/户口本测试样本1011-首页')
+
+image_path = Path('/Users/sxkj/Desktop/1/img')
 image_type = 1
 # 是否旋转
 image_rotate = False
@@ -22,7 +23,8 @@ ocr_address = 'local'  # 'local' 'TXtest' 'TXsb' 'DXtest' 'DXsb'
 
 ocr_name = 'regbook'  # 'cet' 'idcard' 'bankcard' 'regbook' 'schoolcert' 'business_license'
 md_name = 'RE_1.7'
-filed = 'regbook'
+
+filed = 'regbook' # 'cet' 'idcard' 'bankcard' 'regbook_0' 'regbook_1' 'schoolcert' 'business_license'
 
 # 若md_path为None 则默认使用图片父路径为markdown保存路径
 # md_path = '/Users/zeke/work/sx/OCR/HROCR/to_md/example' or image_path.parent
@@ -32,6 +34,7 @@ md_file = parser_path(Path(md_path) / Path(md_name + image_path.stem), image_rot
 
 
 if __name__ == '__main__':
+
     markdown = MD(md_file)
 
     dataset = Dataset(image_path, image_type, ocr_name, ocr_address, filed, image_rotate)

+ 16 - 1
HR_OCR/tools/convert_json.py

@@ -13,22 +13,37 @@ import json
 import base64
 from itertools import chain
 
+<<<<<<< Updated upstream
 url = 'http://192.168.199.27:18060'
 imgs_path = '/Users/zeke/work/sx/OCR/image_data/营业执照90'
+=======
+url = 'http://192.168.199.27:18040'
+imgs_path = '/Users/sxkj/test_script/HR_OCR/户口本测试样本1011-常住人口页'
+>>>>>>> Stashed changes
 
 
 def send_request(img_path):
     with open(img_path, 'rb') as f:
         img_str: str = base64.encodebytes(f.read()).decode('utf-8')
         data = {
-            'image': img_str
+            'image': img_str,
+            'image_type': 0
         }
+<<<<<<< Updated upstream
         # idc_header = {
         #     'Content-Type': 'application/json',
         #     'Authorization': 'Bearer 4e00c444-620b-4d3c-85f4-777e64276f0e'
         # }
         # r = requests.post(f'{url}/ocr_system/business_license', json=data, headers=idc_header)
         r = requests.post(f'{url}/ocr_system/business_license', json=data)
+=======
+        idc_header = {
+            'Content-Type': 'application/json',
+            'Authorization': 'Bearer 4e00c444-620b-4d3c-85f4-777e64276f0e'
+        }
+        r = requests.post(f'{url}/ocr_system/regbook', json=data, headers=idc_header)
+        # r = requests.post(f'{url}/hkbsbtest/regbook', json=data)
+>>>>>>> Stashed changes
         print(r.json())
         return r.json()