Browse Source

fix send_request token错误

zeke-chin 2 years ago
parent
commit
bf079b5c86

+ 2 - 2
HR_OCR/TestAllOcr/test_interface.py

@@ -2,7 +2,7 @@
 Author: zeke-chin zeke-chin@icloud.com
 Date: 2022-09-28 20:28:41
 LastEditors: zeke-chin zeke-chin@icloud.com
-LastEditTime: 2022-09-30 10:06:35
+LastEditTime: 2022-10-11 14:04:22
 FilePath: /to_md/HR_OCR/TestAllOcr/test_interface.py
 Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 '''
@@ -14,7 +14,7 @@ from config import send_request
 image_path = 'image'
 
 # DX_test, DX_sb, DX_test, DX_sb
-envl = 'TX_sb'
+envl = 'DX_test'
 url = config.URL[envl]
 token = config.TOKEN[envl]
 

+ 1 - 1
HR_OCR/to_md/new.py

@@ -95,7 +95,7 @@ def send_request(image: Image, ocr_name, ocr_address, image_type=None):
     config = OCR_CONFIGS[ocr_name][ocr_address]
     headers = {
         'Content-Type': 'application/json',
-        'Authorization': config.token
+        'Authorization': f'Bearer {config.token}'
     }
     data = {
         'image': base64_str,

+ 5 - 5
HR_OCR/to_md/use.py

@@ -2,7 +2,7 @@
 Author: zeke-chin zeke-chin@icloud.com
 Date: 2022-09-28 20:28:41
 LastEditors: zeke-chin zeke-chin@icloud.com
-LastEditTime: 2022-09-30 15:08:48
+LastEditTime: 2022-10-10 21:14:29
 FilePath: /to_md/HR_OCR/to_md/use.py
 Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 '''
@@ -13,15 +13,15 @@ from new import MD, Image, Dataset, parser_path
 
 # config
 # 图片路径
-image_path = Path('/Users/zeke/work/sx/OCR/image_data/户口本9.30/0/img/')
+image_path = Path('/Users/zeke/Downloads/户口本测试样本1011-常住人口页')
 image_type = 0
 # 是否旋转
 image_rotate = False
 ocr_address = 'DXtest'  # 'local' 'TXtest' 'TXsb' 'DXtest' 'DXsb'
 
-ocr_name = 'cet'  # 'cet' 'idcard' 'bankcard' 'regbook' 'schoolcert' 'business_license'
-md_name = 'CET'
-filed = 'cet'
+ocr_name = 'regbook'  # 'cet' 'idcard' 'bankcard' 'regbook' 'schoolcert' 'business_license'
+md_name = 'RBook'
+filed = 'regbook'
 
 # 若md_path为None 则默认使用图片父路径为markdown保存路径
 # md_path = '/Users/zeke/work/sx/OCR/HROCR/to_md/example' or image_path.parent

+ 2 - 2
HR_OCR/tools/convert_json.py

@@ -6,7 +6,7 @@ import base64
 from itertools import chain
 
 url = 'http://aihubpre-idc.digitalyili.com/aiSquare/openApi/reasoning-services/hrocr'
-imgs_path = './HR_OCR/to_md/example/img'
+imgs_path = '/Users/zeke/Downloads/户口本测试样本1011-常住人口页'
 
 def send_request(img_path, image_type = 0):
     with open(img_path, 'rb') as f:
@@ -19,7 +19,7 @@ def send_request(img_path, image_type = 0):
             'Content-Type': 'application/json',
             'Authorization': 'Bearer 4e00c444-620b-4d3c-85f4-777e64276f0e'
         }
-        r = requests.post(f'{url}/cettest/cet', json=data, headers=idc_header)
+        r = requests.post(f'{url}/hkbsbtest/regbook', json=data, headers=idc_header)
         # r = requests.post(f'{url}/hkbsbtest/regbook', json=data)
         print(r.json())
         return r.json()

+ 1 - 1
HR_OCR/tools/suffix.py

@@ -4,7 +4,7 @@ from itertools import chain
 import sys
 
 # conf
-target_path = './HR_OCR/to_md/example/img'
+target_path = '/Users/zeke/Downloads/户口本测试样本1011-常住人口页'
 #suffix = sys.argv[2]
 suffix = 'jpg' if len(sys.argv) != 3 else sys.argv[2]