Spaces:
Sleeping
Sleeping
File size: 2,355 Bytes
d5841ad |
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 |
---
title: Text Detection Demo
emoji: π
colorFrom: blue
colorTo: green
sdk: gradio
sdk_version: 5.49.1
app_file: app.py
pinned: false
license: apache-2.0
---
# π Text Detection Demo
Extract text from any image using OCR (Optical Character Recognition).
## π― What It Does
Upload an image β AI extracts the text β Copy and use!
## π Try it Live
**Demo:** https://huggingface.co/spaces/AlBaraa63/text_detection
## π Files
```
text_detection/
βββ app.py # Gradio web demo
βββ main.py # CLI version
βββ preprocessing.py # Image processing helpers
βββ requirements.txt # Dependencies
βββ packages.txt # System dependencies
βββ README.md # This file
```
## οΏ½οΈ Setup
### 1. Install Tesseract OCR
- **Windows:** Download from [here](https://github.com/UB-Mannheim/tesseract/wiki)
- Install to: `C:\Program Files\Tesseract-OCR`
### 2. Install Python Packages
```bash
pip install -r requirements.txt
```
Or manually:
```bash
pip install opencv-python pytesseract numpy
```
### 3. Test Installation
```bash
python test_tesseract.py
```
## π Usage
### Simple - Run and Enter Path
```bash
python main.py
```
Then enter your image path when asked.
### Example
```bash
python main.py
# Enter: inputs/image.png
```
## π Example
**Input Image:** Screenshot with text
**Output:** Text file with detected text
```
Image: image.png
Size: 869 x 296 pixels
DETECTED TEXT:
Mix - antent - homesick (super slowed)
Mixes are playlists YouTube makes for you
β
Text saved to: output.txt
```
## π How It Works
1. **Load Image** - Read the image file
2. **Preprocess** - Convert to grayscale and enhance
3. **OCR** - Extract text using Tesseract
4. **Save** - Write text to output.txt
## π What's Included
- **1 sample image** in `inputs/` folder for testing
- Works with any image format (PNG, JPG, etc.)
- Clean and minimal - perfect for learning!
## π‘ Tips
- Works best with clear, high-contrast images
- Screenshots work great
- Photos might need better lighting
- Larger images = better accuracy
## οΏ½ Next Steps
Once you understand this basic version, you can:
- Add preprocessing options
- Batch process multiple images
- Add confidence scores
- Try different languages
---
*Simple text detection for learning* π
|