Flask-Uwsgi based endpoints for pytesseract wrapper using Tesseract 4
- built on top of tesseract 4 runtime environment docker image
- exposes functions of pytesseract wrapper
- uses uwsgi for production deployments
#to build the image
docker-compose build
# to run the service
docker-compose up -d
# to stop the service
docker-compose down
import requests
image = open('path_to_image.file', 'rb').read()
# if calling from another service in docker compose
r = requests.post('http://tesseract:8888/image_to_string', files={'file': image})
# if calling from another elsewhere in docker compose
r = requests.post('http://<local_or_aws_endpoint>:8888/image_to_string', files={'file': image})
print(r.text)
# if calling to get readable pdf
r = requests.post('http://<local_or_aws_endpoint>:8888/image_to_readable_pdf', files={'file': image})
# save the readable pdf
with open('output.pdf', 'wb') as f:
f.write(r.content)