Skip to content

πŸ–ΌοΈ An web application that allows users to upload images, extract embedded text using OCR, and store metadata in a searchable database. πŸ” Users can search for specific text to retrieve relevant images, with advanced filters for categories and dates. πŸ“…

Notifications You must be signed in to change notification settings

Abeshith/Enhanced-Image-Search

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

7 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ” Enhanced Image Search

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.


🌟 Overview

  • πŸ“€ 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.

βš™οΈ How It Works

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.


πŸ”„ App Workflow

1️⃣ Upload an Image

Upload Image

2️⃣ Search Using Text Query

Search Query

3️⃣ Search Output Results

Search Output


πŸš€ Installation

  1. Clone the repository πŸ–₯️

    git clone https://github.com/Abeshith/Enhanced-Image-Search.git
    cd Enhanced-Image-Search
  2. Create a virtual environment (optional but recommended) πŸ’»

    python -m venv venv
    venv\Scripts\activate     # On Windows
  3. Install dependencies πŸ“¦

    pip install -r requirements.txt
  4. 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.

πŸ› οΈ Usage

  1. Run the application ▢️
    python app.py
  2. 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.

πŸ”‘ Key Functions

  • πŸ“œ 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

πŸ“ Repo Structure

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

About

πŸ–ΌοΈ An web application that allows users to upload images, extract embedded text using OCR, and store metadata in a searchable database. πŸ” Users can search for specific text to retrieve relevant images, with advanced filters for categories and dates. πŸ“…

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published