ocrapi.py 460 B

123456789101112131415161718192021222324
  1. import requests
  2. import base64
  3. import os
  4. import re
  5. import time
  6. import json
  7. def ocr(path):
  8. with open(path, 'rb') as f:
  9. base64_data = base64.b64encode(f.read())
  10. s = base64_data.decode()
  11. js = json.loads(requests.post('http://106.75.61.190:10811/spooo', json={'b64': s}).text)
  12. print(js)
  13. time.sleep(0.1)
  14. s = js['texts'].replace('<latex>',' ').replace(
  15. '</latex>', ' ')
  16. return s
  17. if __name__ == '__main__':
  18. ...