12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- '''
- Author: zeke-chin zeke-chin@icloud.com
- Date: 2022-09-26 14:58:10
- LastEditors: zeke-chin zeke-chin@icloud.com
- LastEditTime: 2022-09-30 09:59:43
- FilePath: /to_md/HR_OCR/TestAllOcr/config.py
- Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
- '''
- import base64
- import requests
- # 测试url
- TX_test_url = 'http://aihubtest.digitalyili.com/aiSquare/openApi/reasoning-services/rlocrxm'
- TX_sb_url = 'http://aihub.digitalyili.com/aiSquare/openApi/reasoning-services/rlocrxm'
- DX_test_url = 'http://aihubpre-idc.digitalyili.com/aiSquare/openApi/reasoning-services/hrocr'
- DX_sb_url = 'http://aihub-idc.digitalyili.com/aiSquare/openApi/reasoning-services/hrocr'
- URL = {
- 'TX_test': TX_test_url,
- 'TX_sb': TX_sb_url,
- 'DX_test': DX_test_url,
- 'DX_sb': DX_sb_url
- }
- DX = {
- }
- # 测试token
- TX_test = {'Authorization': 'Bearer 8ae1e5f1-1337-4f22-8d46-ff4c110d68fd'}
- TX_sb = {'Authorization': 'Bearer dcae8cc6-0e49-4db8-a2d2-94ef84da3636'}
- DX_test = {'Authorization': 'Bearer 4e00c444-620b-4d3c-85f4-777e64276f0e'}
- DX_sb = {'Authorization': 'Bearer e045de0a-e97f-4f23-b4d5-6a032c39a81e'}
- TOKEN = {
- 'TX_test': TX_test,
- 'TX_sb': TX_sb,
- 'DX_test': DX_test,
- 'DX_sb': DX_sb
- }
- def send_request(image_path, suffix, URL, TOKEN):
- with open(image_path, 'rb') as f:
- img_str: str = base64.encodebytes(f.read()).decode('utf-8')
- r = requests.post(f'{URL}{suffix}', json={'image': img_str, 'image_type': '0'}, headers=TOKEN)
- return r.json()
|