A Python-based REST API for PDF OCR using AI models with PyTorch and Transformers that runs in a Docker container.
Python
37
57 commits
updated May 17, 2024
llm-pdf-ocr-api is a Flask-based web service designed to perform Optical Character Recognition (OCR) on PDF files using machine vision and AI models. Built on PyTorch and Transformers and optimized with NVIDIA CUDA, this API provides two endpoints, one for OCR processing, and one for listing available models. This API is wrapped in a Docker container.
When a user submits a file to the /ocr endpoint, the following steps are executed:
model, threshold_value, kernel_width, kernel_height, and min_area.To install llm-pdf-ocr-api, follow these steps:
Begin by cloning the repository containing the llm-newsletter-generator to your local machine.
git clone https://github.com/samestrin/llm-pdf-ocr-api/
Navigate to the project directory:
cd llm-pdf-ocr-api
Install the required dependencies using pip:
pip install -r src/requirements.txt
Endpoint: /ocr Method: POST
Process a PDF file and return the extracted text.
file: PDF filemodel (optional): Specifies the OCR model to be used for text extraction. Defaults to microsoft/trocr-base-printed if not provided.threshold_value (optional): Determines the threshold value for binary thresholding of images. The default value is 150.kernel_width (optional): Defines the width of the kernel used in morphological operations to clean up the image. It defaults to 20.kernel_height (optional): Specifies the height of the kernel used in morphological operations. The default is 1.min_area (optional): Sets the minimum area of contours that are considered as valid lines of text. The default minimum area is 50.Endpoint: /models Method: GET
Show all AI models available.
The API handles errors gracefully and returns appropriate error responses:
Contributions to this project are welcome. Please fork the repository and submit a pull request with your changes or improvements.
This project is licensed under the MIT License - see the LICENSE file for details.
A Python-based REST API for PDF OCR using AI models with PyTorch and Transformers that runs in a Docker container.
Python
37
57 commits
updated May 17, 2024
llm-pdf-ocr-api is a Flask-based web service designed to perform Optical Character Recognition (OCR) on PDF files using machine vision and AI models. Built on PyTorch and Transformers and optimized with NVIDIA CUDA, this API provides two endpoints, one for OCR processing, and one for listing available models. This API is wrapped in a Docker container.
When a user submits a file to the /ocr endpoint, the following steps are executed:
model, threshold_value, kernel_width, kernel_height, and min_area.To install llm-pdf-ocr-api, follow these steps:
Begin by cloning the repository containing the llm-newsletter-generator to your local machine.
git clone https://github.com/samestrin/llm-pdf-ocr-api/
Navigate to the project directory:
cd llm-pdf-ocr-api
Install the required dependencies using pip:
pip install -r src/requirements.txt
Endpoint: /ocr Method: POST
Process a PDF file and return the extracted text.
file: PDF filemodel (optional): Specifies the OCR model to be used for text extraction. Defaults to microsoft/trocr-base-printed if not provided.threshold_value (optional): Determines the threshold value for binary thresholding of images. The default value is 150.kernel_width (optional): Defines the width of the kernel used in morphological operations to clean up the image. It defaults to 20.kernel_height (optional): Specifies the height of the kernel used in morphological operations. The default is 1.min_area (optional): Sets the minimum area of contours that are considered as valid lines of text. The default minimum area is 50.Endpoint: /models Method: GET
Show all AI models available.
The API handles errors gracefully and returns appropriate error responses:
Contributions to this project are welcome. Please fork the repository and submit a pull request with your changes or improvements.
This project is licensed under the MIT License - see the LICENSE file for details.