vision-writer-py
Made with love from Oberon Studios
About
Vision Writer is a PDF to Txt converter, build using Google Cloud Vision API. It is implemented in Python, using Flask framework to bootstrap api.
Architecture and app flow
First, user submits post request to Flask server with pdf as a payload. Server converts pdf to jpg(multiple pages), and sends converted pictures to Google Cloud Vision API, page by page. On return, server extracts text data, and writes it to a text file, appedning page after page. Name of the txt file, is SHA1 hash of current timestamp. Finally, server responsd with txt file as attachment.
Build with:
- Flask (Python)
- Google Cloud Vision API
Documentation
Prereqs
- Python 3.5.x or newer
- Google Cloud account with Cloud Vision API enabled Read more
Installation
First, follow this guide to get your Google credentials, and save them in root directory as config.json
Configure virtual environment (In this example, I am using Virtualenv, but you are free to do it your own way)
First, check Python version installed
On Linux, one of the possible ways is to enter $ /usr/bin/python in your terminal and hit Tab key twice
This would show all the available vesrsions
python python3 python3.6m python3m
python2 python3.6 python3.6m-config python3m-config
python2.7 python3.6-config python3-config
Now, create environment with desired version of Python specified, as --python=PY_VERSION (Note: Django 2.x.. requres Python 3.x.. version!)
$ virtualenv MY_ENV --python=python3.6
Activate your environment, and install dependencies
Note: If your environment name differs from MY_ENV, you would have to use source YOUR_ENV_NAME/bin/activate as first command
$ source activate && pip install -r requirements_dev.txt
Run
Set flask server file, and google config file locations as env variables
export FLASK_APP=server.py
export GOOGLE_APPLICATION_CREDENTIALS="<path>/config.json"
For permanent affect, make sure to add this two lines to your ~/.bash_profile
Finally, you are ready to launch your app (-p 3000 option is for custom port number)
flask run -h localhost -p 3000
Log in or sign up for Devpost to join the conversation.