File size: 2,263 Bytes
c542962
 
 
 
 
 
 
 
 
 
 
6a25d63
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---
title: GOT OCR
emoji: 👀
colorFrom: green
colorTo: indigo
sdk: streamlit
sdk_version: 1.38.0
app_file: app.py
pinned: false
license: mit
---

# Image Text OCR using GOT (General OCR Theory)

This Streamlit application provides an interface for Optical Character Recognition (OCR) using the GOT (General OCR Theory) model. Users can upload images, and the application will extract text from them. Additionally, it includes a search feature to highlight specific words or phrases in the extracted text.

## Demo

Try out the live demo on huggingface: [GOT-OCR-Space](https://huggingface.co/spaces/akhil-vaidya/GOT-OCR)

## Setup

1. Clone this repository to your local machine.
2. Ensure you have Python 3.7+ installed.
3. Install the required dependencies:

   ```
   pip install -r requirements.txt
   ```

## Usage

To run the application locally:

```
streamlit run app.py
```

Then, open your web browser and navigate to the URL provided by Streamlit (usually `http://localhost:8501`).

## Features

- Image upload: Supports JPG, PNG, and JPEG formats.
- Text extraction: Uses the GOT model to extract text from uploaded images.
- Search functionality: Allows users to search for specific words or phrases in the extracted text, highlighting the matches.

## Model Information

This application uses the CPU version of the GOT (General OCR Theory) model. The model is loaded from the Hugging Face model hub:

- Model: `srimanth-d/GOT_CPU`
- Tokenizer: `srimanth-d/GOT_CPU`

While the code includes functions for GPU model initialization, the deployed version uses the CPU model due to limitations in the Hugging Face deployment environment. This may result in slower processing times but ensures compatibility across different deployment scenarios.

## Note on Performance

The use of the CPU model might lead to slower processing times compared to a GPU-enabled version. However, this trade-off ensures that the application can run in environments without GPU support, such as the Hugging Face deployment platform.

## Additional Information

- The application creates a directory named `images` to temporarily store uploaded images.
- The search functionality is case-insensitive and highlights all occurrences of the search term in the extracted text.