Spaces:
Sleeping
Sleeping
File size: 5,185 Bytes
cf50bb4 89a71b2 cf50bb4 89a71b2 cf50bb4 89a71b2 cf50bb4 89a71b2 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
---
title: OCR Assignment
emoji: 🔥
colorFrom: gray
colorTo: blue
sdk: streamlit
sdk_version: 1.38.0
app_file: app.py
pinned: true
short_description: OCR and Document Search Web App
thumbnail: >-
https://cdn-uploads.huggingface.co/production/uploads/66f5a2b7e8b5fab5a730b3dd/fj1fjy4CEmOh8xIzY4Xae.jpeg
---
# OCR and Document Search Web Application Prototype Using GOT-OCR 2.0
This repository contains a **Streamlit**-based web application that leverages the **GOT 2.0** OCR model for optical character recognition (OCR) and document search functionality. The application is deployed on Hugging Face Spaces, running on **CPU**, which may cause slightly slower processing times.
## Features
- **OCR:** Upload an image and extract text using the GOT 2.0 model.
- **Document Search:** Search for specific words or phrases in the extracted text.
- **Language Support:** Primarily supports English and Chinese, with limited accuracy for Hindi.
- **Deployment:** Hosted on Hugging Face Spaces and optimized for CPU-based execution.
## Table of Contents
- [Installation](#installation)
- [Running Locally](#running-locally)
- [Deployment](#deployment)
- [Usage](#usage)
- [GOT 2.0 Model Details](#got-20-model-details)
- [Limitations](#limitations)
## Installation
Follow these steps to set up the project environment:
### 1. Clone the Repository
```bash
git clone https://github.com/Tejasva-Maurya/OCR-and-Document-Search-Web-Application-Prototype-Using-GOT-OCR-2.0.git
cd OCR-and-Document-Search-Web-Application-Prototype-Using-GOT-OCR-2.0
```
### 2. Set up a Virtual Environment
Create a virtual environment to keep the project dependencies isolated.
For Python 3:
```bash
python3 -m venv venv
source venv/bin/activate # On Windows use: venv\Scripts\activate
```
### 3. Install Dependencies
Install the required Python packages from `requirements.txt`:
```bash
pip install -r requirements.txt
```
## Running Locally
To run the application locally, follow these steps:
### 1. Run the Streamlit App
```bash
streamlit run app.py
```
This will start a local server, and you can access the application in your browser at `http://localhost:8501`.
### 2. Upload Images and Perform OCR
Once the app is running, upload an image (e.g., JPG, PNG, JPEG), and the OCR model will extract the text. You can search for specific words or phrases within the extracted text.
### 3. Project Structure
- `app.py`: Main application file.
- `images/`: Directory where uploaded images are saved.
## Deployment
The application is deployed on **Hugging Face Spaces** using **Streamlit**. Due to **GPU-related complexities on Hugging Face**, the application runs on **CPU** by default. This might result in slower performance during OCR processing, but it avoids potential issues related to GPU execution.
### 1. Set up Hugging Face Spaces
- Create a new repository on [Hugging Face Spaces](https://huggingface.co/spaces).
- Select **Streamlit** as the framework for deployment.
### 2. Upload Your Code
Push your code to the Hugging Face Spaces repository you just created.
```bash
git add .
git commit -m "Initial commit"
git push origin main
```
### 3. Configure the `requirements.txt`
Ensure your `requirements.txt` is correctly set up for the Hugging Face environment to install the necessary dependencies.
### 4. Deploy
After pushing the code, Hugging Face Spaces will automatically build and deploy your app. You can access the app through the Hugging Face URL provided.
## GOT 2.0 Model Details
The GOT 2.0 model is an advanced OCR model initially developed to support **English** and **Chinese** languages. The model uses a combination of pre-trained transformers and optimized tokenization techniques to extract text from images efficiently.
- **Pre-trained on English and Chinese:** While the model performs well for these languages, it may exhibit reduced accuracy when used for other languages like Hindi.
- **CPU Performance:** The model is optimized for **GPU**, but this application runs it on **CPU** due to Hugging Face limitations. This results in slower inference times.
- **Hugging Face Model:** The application loads the model from the Hugging Face repository: `srimanth-d/GOT_CPU`.
## Limitations
### 1. **CPU Processing**
- The application runs on CPU, which may result in longer processing times. GPU deployment is not feasible due to Hugging Face constraints on GPU support.
### 2. **Hindi Language Support**
- The GOT 2.0 model was not specifically trained for Hindi, and the OCR accuracy for Hindi text is **limited**. It works best with **English** and **Chinese** images.
### 3. **Model Size and Performance**
- The GOT 2.0 model is resource-intensive, and even on CPU, it may take additional time to process larger images or images with complex text.
## Usage
1. Open the app and upload an image to perform OCR.
2. After the text is extracted, use the search box to find specific words or phrases in the document.
3. The app will highlight the search terms in the extracted text and indicate whether the term was found.
---
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference |