Spaces:
Running
Running
Update README.md
Browse files
README.md
CHANGED
@@ -1,6 +1,5 @@
|
|
1 |
---
|
2 |
title: ' Ocr Model'
|
3 |
-
emoji: 🐠
|
4 |
colorFrom: green
|
5 |
colorTo: red
|
6 |
sdk: streamlit
|
@@ -8,5 +7,91 @@ sdk_version: 1.38.0
|
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
1 |
---
|
2 |
title: ' Ocr Model'
|
|
|
3 |
colorFrom: green
|
4 |
colorTo: red
|
5 |
sdk: streamlit
|
|
|
7 |
app_file: app.py
|
8 |
pinned: false
|
9 |
---
|
10 |
+
# OCR Application with Real-Time Token Streaming
|
11 |
+
|
12 |
+
This project is a Streamlit-based web application that uses the.Qwen2VL model to perform Optical Character Recognition (OCR) on uploaded images.
|
13 |
+
It features real-time token streaming and keyword search functionality, deployed on Hugging Face Spaces.
|
14 |
+
|
15 |
+
# Features
|
16 |
+
|
17 |
+
- Image upload and display
|
18 |
+
- Real-time OCR text extraction with token streaming
|
19 |
+
- Keyword search in extracted text
|
20 |
+
- Support for multiple languages (including Hindi and English)
|
21 |
+
|
22 |
+
# Prerequisites
|
23 |
+
|
24 |
+
- Python 3.7+
|
25 |
+
- pip (Python package manager)
|
26 |
+
|
27 |
+
# Installation
|
28 |
+
|
29 |
+
1. Clone this repository:
|
30 |
+
```
|
31 |
+
git clone <your-repository-url>
|
32 |
+
cd <your-project-directory>
|
33 |
+
```
|
34 |
+
|
35 |
+
2. Create a virtual environment (optional but recommended):
|
36 |
+
```
|
37 |
+
python -m venv venv
|
38 |
+
source venv/bin/activate # On Windows, use `venv\Scripts\activate`
|
39 |
+
```
|
40 |
+
|
41 |
+
3. Install the required packages:
|
42 |
+
```
|
43 |
+
pip install -r requirements.txt
|
44 |
+
```
|
45 |
+
|
46 |
+
# Running the Application Locally
|
47 |
+
|
48 |
+
1. Ensure you're in the project directory and your virtual environment is activated (if you're using one).
|
49 |
+
|
50 |
+
2. Run the Streamlit app:
|
51 |
+
```
|
52 |
+
streamlit run app.py
|
53 |
+
```
|
54 |
+
|
55 |
+
3. Open your web browser and navigate to the URL provided by Streamlit (usually `http://localhost:8501`).
|
56 |
+
|
57 |
+
# Usage
|
58 |
+
|
59 |
+
1. Upload an image using the file uploader.
|
60 |
+
2. Wait for the OCR process to complete. You'll see the extracted text appear in real-time.
|
61 |
+
3. Use the keyword search feature to find specific words in the extracted text.
|
62 |
+
|
63 |
+
# Deployment on Hugging Face Spaces
|
64 |
+
|
65 |
+
This application is deployed on Hugging Face Spaces using the Streamlit SDK. Here's an overview of the deployment process:
|
66 |
+
|
67 |
+
1. Create a Hugging Face account: If you haven't already, sign up at [huggingface.co](https://huggingface.co/).
|
68 |
+
|
69 |
+
2. Create a new Space:
|
70 |
+
- Go to [huggingface.co/spaces](https://huggingface.co/spaces) and click on "Create new Space".
|
71 |
+
- Choose "Streamlit" as the SDK.
|
72 |
+
- Set up your Space with a name and visibility settings.
|
73 |
+
|
74 |
+
3. Prepare your repository:
|
75 |
+
- Ensure your `app.py` and `requirements.txt` are in the root of your repository.
|
76 |
+
- Add a `README.md` file (this file) to your repository.
|
77 |
+
|
78 |
+
4. Configure the Space:
|
79 |
+
- In your Space's settings, under "Repository", link your GitHub repository.
|
80 |
+
- Set the Python version if necessary.
|
81 |
+
- Add any required secrets or environment variables.
|
82 |
+
|
83 |
+
5. Deploy:
|
84 |
+
- Hugging Face Spaces will automatically deploy your app when you push changes to your linked repository.
|
85 |
+
- You can also manually trigger a rebuild from the Space's settings.
|
86 |
+
|
87 |
+
6. Access your deployed app:
|
88 |
+
- Your app will be available at `https://huggingface.co/spaces/<your-username>/<your-space-name>`.
|
89 |
+
|
90 |
+
Remember to update your `requirements.txt` file if you make any changes to your project dependencies.
|
91 |
+
|
92 |
+
# Notes
|
93 |
+
|
94 |
+
- The application uses CPU for inference by default. If you have a CUDA-capable GPU available on your deployment platform, you can modify the `device_map` and `to()` calls in `app.py` to use GPU acceleration.
|
95 |
+
- The model and processor are cached using Streamlit's `@st.cache_resource` decorator to improve performance on subsequent runs.
|
96 |
|
97 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|