Adding README
Browse files
README.md
CHANGED
@@ -1,138 +1,14 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
### 1. Install Dependencies
|
17 |
-
|
18 |
-
```bash
|
19 |
-
pip install -r requirements.txt
|
20 |
-
```
|
21 |
-
|
22 |
-
### 2. Set Up Supabase
|
23 |
-
|
24 |
-
1. Create a Supabase project at [supabase.com](https://supabase.com)
|
25 |
-
2. Get your project URL and anon key from the project settings
|
26 |
-
3. Run the SQL script in your Supabase SQL editor:
|
27 |
-
|
28 |
-
```sql
|
29 |
-
-- Copy and paste the contents of supabase_setup.sql
|
30 |
-
```
|
31 |
-
|
32 |
-
### 3. Configure API Keys
|
33 |
-
|
34 |
-
Edit `ocr_secrets.py` and add your API keys:
|
35 |
-
|
36 |
-
```python
|
37 |
-
# Store your API keys here
|
38 |
-
GEMINI_API_KEY = "your-gemini-api-key"
|
39 |
-
MISTRAL_API_KEY = "your-mistral-api-key"
|
40 |
-
|
41 |
-
# Supabase credentials
|
42 |
-
SUPABASE_URL = "your-supabase-url"
|
43 |
-
SUPABASE_KEY = "your-supabase-anon-key"
|
44 |
-
```
|
45 |
-
|
46 |
-
### 4. Run the Application
|
47 |
-
|
48 |
-
```bash
|
49 |
-
python ocr_compare_app.py
|
50 |
-
```
|
51 |
-
|
52 |
-
The app will be available at the provided Gradio URL.
|
53 |
-
|
54 |
-
## How It Works
|
55 |
-
|
56 |
-
### OCR Process
|
57 |
-
1. User uploads an image
|
58 |
-
2. Both Gemini and Mistral process the image for OCR
|
59 |
-
3. Results are displayed side by side in markdown format
|
60 |
-
4. User can vote for the better result
|
61 |
-
|
62 |
-
### Voting System
|
63 |
-
- Each user session allows only one vote
|
64 |
-
- Votes are stored in Supabase with the original image
|
65 |
-
- Session can be reset to allow another vote
|
66 |
-
|
67 |
-
### Database Schema
|
68 |
-
The app uses a single `votes` table with the following structure:
|
69 |
-
- `id`: Unique identifier for each vote
|
70 |
-
- `session_id`: User session identifier
|
71 |
-
- `voted_for`: Which AI the user voted for (Gemini/Mistral)
|
72 |
-
- `gemini_text`: OCR result from Gemini
|
73 |
-
- `mistral_text`: OCR result from Mistral
|
74 |
-
- `image_data`: Base64 encoded original image
|
75 |
-
- `created_at`: Timestamp of the vote
|
76 |
-
|
77 |
-
## API Requirements
|
78 |
-
|
79 |
-
### Gemini API
|
80 |
-
- Get your API key from [Google AI Studio](https://makersuite.google.com/app/apikey)
|
81 |
-
- Uses the `gemini-2.5-flash` model
|
82 |
-
|
83 |
-
### Mistral API
|
84 |
-
- Get your API key from [Mistral AI](https://console.mistral.ai/)
|
85 |
-
- Uses the `mistral-ocr-latest` model
|
86 |
-
|
87 |
-
## File Structure
|
88 |
-
|
89 |
-
```
|
90 |
-
├── ocr_compare_app.py # Main application
|
91 |
-
├── database.py # Database operations
|
92 |
-
├── ocr_secrets.py # API keys and configuration
|
93 |
-
├── requirements.txt # Python dependencies
|
94 |
-
├── supabase_setup.sql # Database schema
|
95 |
-
└── README.md # This file
|
96 |
-
```
|
97 |
-
|
98 |
-
## Features in Detail
|
99 |
-
|
100 |
-
### 🔍 OCR & Vote Tab
|
101 |
-
- Upload images via file or paste
|
102 |
-
- View OCR results from both AIs
|
103 |
-
- Vote for the better result
|
104 |
-
- Reset session to vote again
|
105 |
-
|
106 |
-
### 📋 Previous Votes Tab
|
107 |
-
- View all previous votes
|
108 |
-
- See the original images and OCR results
|
109 |
-
- Refresh to get latest data
|
110 |
-
|
111 |
-
### 🏆 Leaderboard Tab
|
112 |
-
- Real-time vote statistics
|
113 |
-
- Percentage breakdown
|
114 |
-
- Current winner display
|
115 |
-
- Refresh to update stats
|
116 |
-
|
117 |
-
## Troubleshooting
|
118 |
-
|
119 |
-
### Common Issues
|
120 |
-
|
121 |
-
1. **Import Errors**: Make sure all dependencies are installed
|
122 |
-
2. **API Errors**: Verify your API keys are correct
|
123 |
-
3. **Database Errors**: Check your Supabase credentials and run the setup SQL
|
124 |
-
4. **Image Processing**: Ensure images are in supported formats (JPEG, PNG, etc.)
|
125 |
-
|
126 |
-
### Error Messages
|
127 |
-
|
128 |
-
- `"You have already voted"`: Reset your session to vote again
|
129 |
-
- `"OCR error"`: Check your API keys and internet connection
|
130 |
-
- `"Database error"`: Verify Supabase configuration
|
131 |
-
|
132 |
-
## Contributing
|
133 |
-
|
134 |
-
Feel free to submit issues and enhancement requests!
|
135 |
-
|
136 |
-
## License
|
137 |
-
|
138 |
-
This project is open source and available under the MIT License.
|
|
|
1 |
+
---
|
2 |
+
title: OCRArena
|
3 |
+
emoji: 👀
|
4 |
+
colorFrom: gray
|
5 |
+
colorTo: gray
|
6 |
+
sdk: gradio
|
7 |
+
sdk_version: 5.38.2
|
8 |
+
app_file: app.py
|
9 |
+
pinned: false
|
10 |
+
hf_oauth: true
|
11 |
+
short_description: A leaderboard for OCR algorithms
|
12 |
+
---
|
13 |
+
|
14 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|