config.py 1.6 KB

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