Image-to-text OCR microservice built with Python using FastAPI and Tesseract
View Docs
Β·
Report Bug
Β·
Request Feature
Table of Contents
Porcupyne is an image-to-text microservice, powered by Google Tesseract OCR, that can be easily incorporated in any application via a simple-to-use API built with FastAPI. The whole microservice is containerized using Docker, making it easier for anyone to set up a local copy and bend it to their needs.
The microservice also cleans and processes the uploaded images with OpenCV; improving the OCR predictions of the Tesseract model.
It's extremely easy to use the Porcupyne OCR service. One simply needs to upload an image file they want converted via an HTTP POST request to https://porcupyne.herokuapp.com/convert/
and a JSON response with the results obtained after applying OCR will be recieved back.
The request body will be of the form of a multipart form.
You can use your preffered API client to test it out. Example Python usage is also provided below:
python3 -m pip install requests
import requests
url = "https://porcupyne.onrender.com/convert"
img_path = "/downloads/img.png"
files = {"file": open(img_path, "rb")}
response = requests.post(url, files=files)
if response.status_code == 200:
print(response.json())
Output:
{
"results": {
"raw": "It was the best of\ntimes, it was the worst\nof times, it was the age\nof wisdom, it was the\nage of foolishness...\n\f",
"cleaned": "It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness...",
"lines": [
"It was the best of",
"times, it was the worst",
"of times, it was the age",
"of wisdom, it was the",
"age of foolishness...",
"\f"
]
}
}
To get a local copy up and running follow these simple steps.
Install Docker. Instructions can be found here in the official docs.
- Clone the repo
git clone https://github.com/outoflaksh/porcupyne.git
- Change into the base directory.
cd porcupyne
- Build the Docker image.
docker build -t porcupyne .
- Run the Docker container.
docker run porcupyne
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request