docker run -p 7860:7860 --name ocr-text 10301998/ocr-text:v1
272
OCR Text Docker Image
This Docker image provides an OCR (Optical Character Recognition) application using three different OCR libraries: PaddleOCR, EasyOCR, and KerasOCR. The application is built using Python and Gradio for the web interface. Features
PaddleOCR: An easy-to-use OCR library developed by PaddlePaddle.
KerasOCR: A high-level OCR tool built with Keras and TensorFlow.
EasyOCR: A powerful OCR library that supports multiple languages.
The user can upload an image and select one of the OCR methods to extract text from the image. Installation
To build and run this Docker image, you need to have Docker installed on your machine. Build the Docker Image
Clone the repository or download the Dockerfile and other required files.
Open a terminal and navigate to the directory containing the Dockerfile. Build the Docker image using the following command:
sh
docker build -t ocr-text .
Run the Docker Container
Once the image is built, you can run the Docker container using the following command:
sh
docker run -p 7860:7860 ocr-text
This command will start the OCR application and make it accessible via http://localhost:7860. Usage
Open a web browser and go to http://localhost:7860.
You will see a user interface with an option to upload an image and select an OCR method (PaddleOCR, EasyOCR, KerasOCR). Upload an image and select the desired OCR method.
Click the "Submit" button to extract text from the uploaded image.
The extracted text will be displayed in the output textbox.
Code Explanation
The code consists of several parts: Importing Required Libraries
The necessary libraries such as Gradio, TensorFlow, Keras-OCR, EasyOCR, PaddleOCR, and others are imported. OCR Methods
Three OCR methods are defined:
ocr_with_paddle: Uses PaddleOCR to extract text from an image.
ocr_with_keras: Uses KerasOCR to extract text from an image.
ocr_with_easy: Uses EasyOCR to extract text from an image.
Utility Functions
Utility functions for image preprocessing such as converting an image to grayscale and thresholding are defined. Generate OCR
The generate_ocr function is the main function that takes the selected OCR method and image as input and returns the extracted text. User Interface
The Gradio interface is created with an image upload option, a radio button to select the OCR method, and a textbox to display the extracted text. Launching the Interface
The Gradio interface is launched, making the OCR application accessible via a web browser. Dockerfile
The Dockerfile sets up the environment to run the OCR application.
Dockerfile
# Use an official Python runtime as a parent image
FROM python:3.8-slim
# Set the working directory in the container
WORKDIR /app
# Copy the current directory contents into the container at /app
COPY . /app
# Install any needed packages specified in requirements.txt
RUN pip install --no-cache-dir -r requirements.txt
# Make port 7860 available to the world outside this container
EXPOSE 7860
# Define environment variable
ENV NAME ocr-text
# Run the application
CMD ["python", "app.py"]
Conclusion
This Docker image provides a convenient way to run an OCR application using multiple OCR methods. By using this Docker image, you can easily extract text from images using PaddleOCR, EasyOCR, or KerasOCR.
Content type
Image
Digest
sha256:d6297d5f9…
Size
4 GB
Last updated
about 2 years ago
docker pull 10301998/ocr-text:v2