Spaces:
Sleeping
Sleeping
| 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* π | |