Spaces:
Sleeping
Sleeping
akhil-vaidya
commited on
Commit
•
6a25d63
1
Parent(s):
2061428
readme
Browse files
README.md
CHANGED
@@ -9,3 +9,55 @@ app_file: app.py
|
|
9 |
pinned: false
|
10 |
license: mit
|
11 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
pinned: false
|
10 |
license: mit
|
11 |
---
|
12 |
+
|
13 |
+
# Image Text OCR using GOT (General OCR Theory)
|
14 |
+
|
15 |
+
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.
|
16 |
+
|
17 |
+
## Demo
|
18 |
+
|
19 |
+
Try out the live demo on huggingface: [GOT-OCR-Space](https://huggingface.co/spaces/akhil-vaidya/GOT-OCR)
|
20 |
+
|
21 |
+
## Setup
|
22 |
+
|
23 |
+
1. Clone this repository to your local machine.
|
24 |
+
2. Ensure you have Python 3.7+ installed.
|
25 |
+
3. Install the required dependencies:
|
26 |
+
|
27 |
+
```
|
28 |
+
pip install -r requirements.txt
|
29 |
+
```
|
30 |
+
|
31 |
+
## Usage
|
32 |
+
|
33 |
+
To run the application locally:
|
34 |
+
|
35 |
+
```
|
36 |
+
streamlit run app.py
|
37 |
+
```
|
38 |
+
|
39 |
+
Then, open your web browser and navigate to the URL provided by Streamlit (usually `http://localhost:8501`).
|
40 |
+
|
41 |
+
## Features
|
42 |
+
|
43 |
+
- Image upload: Supports JPG, PNG, and JPEG formats.
|
44 |
+
- Text extraction: Uses the GOT model to extract text from uploaded images.
|
45 |
+
- Search functionality: Allows users to search for specific words or phrases in the extracted text, highlighting the matches.
|
46 |
+
|
47 |
+
## Model Information
|
48 |
+
|
49 |
+
This application uses the CPU version of the GOT (General OCR Theory) model. The model is loaded from the Hugging Face model hub:
|
50 |
+
|
51 |
+
- Model: `srimanth-d/GOT_CPU`
|
52 |
+
- Tokenizer: `srimanth-d/GOT_CPU`
|
53 |
+
|
54 |
+
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.
|
55 |
+
|
56 |
+
## Note on Performance
|
57 |
+
|
58 |
+
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.
|
59 |
+
|
60 |
+
## Additional Information
|
61 |
+
|
62 |
+
- The application creates a directory named `images` to temporarily store uploaded images.
|
63 |
+
- The search functionality is case-insensitive and highlights all occurrences of the search term in the extracted text.
|
app.py
CHANGED
@@ -82,7 +82,7 @@ def highlight_text(text, search_term):
|
|
82 |
pattern = re.compile(re.escape(search_term), re.IGNORECASE)
|
83 |
return pattern.sub(lambda m: f'<span style="background-color: yellow;">{m.group()}</span>', text)
|
84 |
|
85 |
-
st.title("Image Text OCR - GOT
|
86 |
st.write("Upload an image for OCR")
|
87 |
|
88 |
MODEL, PROCESSOR = init_model()
|
|
|
82 |
pattern = re.compile(re.escape(search_term), re.IGNORECASE)
|
83 |
return pattern.sub(lambda m: f'<span style="background-color: yellow;">{m.group()}</span>', text)
|
84 |
|
85 |
+
st.title("Image Text OCR - GOT-OCR2.0")
|
86 |
st.write("Upload an image for OCR")
|
87 |
|
88 |
MODEL, PROCESSOR = init_model()
|