Skip to content

The Arabic OCR Tool is a Streamlit-based web application that enables users to easily extract text from images containing Arabic characters. Leveraging the EasyOCR library, this tool simplifies the process of Optical Character Recognition (OCR) for Arabic text.

Notifications You must be signed in to change notification settings

Shashank545/middle-east-easy-ocr

Repository files navigation

Arabic_OCR

alt text
This repo contains Arabic OCR App. The APP can be used to extract the Arabic text from the images. This was built based on the EasyOCR library. EsayOCR built detection/recognition model to detect and recognize the characters and words. For detection part they used the pretrained model for CRAFT algorithm. For recognition they built a CRNN model. For our case, we used the two pretrained model for Arabic language. To create the wep app, we used the Streamlit library.

App

The app deployed by Streamlit share. But the streamlit share dose not provide gpu at the backend only cpu. The app can run on cpu but with slow performance. So, the text extraction process can take from 2 to 3 minutes on cpu, extracting text from the same image with gpu in backend can lead to a huge improvement in the performance and the process can take 13 sec at average. So, we need to take it into consideration when trying it.

You can try the app on the streamlit sharing cloud on this link Arabic OCR

Installation

1. Install via conda

In this step we assume that conda is preinstalled on the machine. If conda is not installed you can follow the steps on the that link

  1. At first we need to clone the repo to the local machine.
git clone https://github.com/Shashank545/Arabic_OCR.git
  1. Create a new conda enviroment to run the app inside it.
conda create --name arabic_ocr
conda activate arabic_ocr
  1. Install the required python packages
pip install -r requirements.txt
  1. Run the app
streamlit run app.py

The command need to run from the folder that contains the repo files. It will generate two links you can go throgh http://localhost:8501 to run the app on the local host.

2. Run via docker container

In this step we assume that Docker is running on your machine.

  1. Clone the repo silmilar to conda installtion.
  2. Convert directory to the repo location.
  3. Build a docker image.
docker image build -t arabic_ocr:app 
  1. Run the image
docker run -p 8501:8501 arabic_ocr:app 

After running the image we can go to http://localhost:8501 to run the app.

Note

  • The first time running the app it may take time (some moments) to download the pretrained models that used. The time depends on the network speed. Then the pretrained models will be saved to used later.
  • The app is running faster with the machine that contains Nvidia gpus. If the gpu is not availble the app will run but with slow performance.

New README from ChatGPT

Explanation: Imports: Import necessary libraries including streamlit, numpy, PIL, time, easyocr, cv2, fitz (PyMuPDF), and io. Caching: Use Streamlit's @st.cache_data and @st.cache_resource decorators to cache functions that process images and OCR results to improve performance. Image Processing: The get_image function opens and converts the uploaded image to a NumPy array. PDF Processing: The extract_images_from_pdf function extracts images from the uploaded PDF file using fitz (PyMuPDF). It reads the PDF file from the uploaded file stream, iterates through the pages, and extracts images. OCR Processing: The get_reader_lang function initializes the EasyOCR reader with the specified language. The get_result function performs OCR on the given image. Main Function: The main function sets up the Streamlit interface, handles file uploads, processes the uploaded files (image or PDF), and displays the results.

Steps: Upload an image or PDF file using the sidebar. Click the "Start OCR" button to process the uploaded file. The application displays the original image and extracted text in two columns. This code ensures that both image and PDF uploads are handled correctly and processed for Arabic OCR using EasyOCR.

About

The Arabic OCR Tool is a Streamlit-based web application that enables users to easily extract text from images containing Arabic characters. Leveraging the EasyOCR library, this tool simplifies the process of Optical Character Recognition (OCR) for Arabic text.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published