A powerful image-based search application that allows users to upload an image, search using text queries, and receive relevant image results based on the search criteria. This project leverages deep learning and feature extraction to improve image search accuracy.
- π€ Upload an image and extract text features.
- π Search using text queries to find matching images.
- π― Retrieve relevant images based on the search.
- π₯ Integrates OCR (Optical Character Recognition) using
pytesseract
to extract text from images. - π Stores extracted text and metadata in an
SQLite database
for efficient search and retrieval.
The application extracts text from uploaded images using pytesseract
and stores the extracted text, along with metadata, in an SQLite database. Users can search for text queries, and matching images are retrieved based on stored text content.
-
Clone the repository π₯οΈ
git clone https://github.com/Abeshith/Enhanced-Image-Search.git cd Enhanced-Image-Search
-
Create a virtual environment (optional but recommended) π»
python -m venv venv venv\Scripts\activate # On Windows
-
Install dependencies π¦
pip install -r requirements.txt
-
Download Tesseract Model π₯
- [Download Tesseract Model]
- After downloading, navigate to
Environment Variables
- Set up the path:
C:\Program Files\Tesseract-OCR
- Open CMD and type:
tesseract --version
- If installed correctly, it will display the installed version.
- Run the application
βΆοΈ python app.py
- Open in browser: π
- Go to
http://127.0.0.1:5000/
to access the web interface. - π€ Upload an image and enter a text-based search query.
- πΌ View the retrieved results.
- Go to
-
π Extract Text from Images:
from PIL import Image import pytesseract def extract_text_from_image(image_path): img = Image.open(image_path) text = pytesseract.image_to_string(img) print(f"Extracted Text: {text}") return text
-
π Store Extracted Data in Database:
import sqlite3 def save_image_data(image_name, text, date, category): conn = sqlite3.connect('images.db') cursor = conn.cursor() cursor.execute('''INSERT INTO image_data (image_name, text_content, date, category) VALUES (?, ?, ?, ?)''', (image_name, text, date, category)) conn.commit() conn.close()
-
π Search for Images Based on Text Query:
def search_text(query): conn = sqlite3.connect('images.db') cursor = conn.cursor() cursor.execute("SELECT * FROM image_data WHERE text_content LIKE ?", ('%' + query.lower() + '%',)) results = cursor.fetchall() conn.close() return results
Enhanced-Image-Search/
β-- app.py # Main application script
β-- templates/
β βββ index.html # Webpage for uploading and searching images
β βββ results.html # Webpage for displaying the search results
β βββ view_db.html # Webpage for displaying database
β-- requirements.txt # Dependencies
β-- images.db # SQLite database storing extracted text data
β-- uploads/ # Directory storing the uploaded images
|-- outputs/ # Directory display output images