RelevImageSearch is a Content-Based Image Retrieval (CBIR) system built with Flask. It allows users to securely register, upload images, and perform image searches based on visual content rather than text keywords. The system incorporates a range of feature extraction techniques and a feedback-driven search refinement process to deliver more accurate and relevant search results over time.
- User Authentication: Secure registration, login, and logout functionalities.
- Image Upload and Management: Users can upload and categorize images.
- Advanced Feature Extraction: Extracts diverse characteristics from images, including color, texture, shape, and local keypoints.
- Relevance Feedback: Iteratively refines search results based on user feedback.
- RESTful API: Provides endpoints for retrieving image descriptors.
- Feature Visualization: Offers insights into how images are represented internally.
- Session Management: Uses Flask-Session for maintaining user sessions.
Effective image retrieval depends on extracting meaningful features that represent an image’s visual content. By combining different feature types, we can capture various aspects of an image and improve the reliability of retrieval.
Summarizing the color distribution helps represent the overall color composition of an image. By using histograms that count how often certain color ranges occur, we can quickly compare images based on their predominant hues and intensities.
Instead of considering all colors, we identify a small set of the most common colors. K-Means clustering groups similar colors and picks representative ones, simplifying comparisons.
Gabor filters help capture the texture patterns in an image. By responding to edges, frequencies, and orientations, these filters provide a way to quantify the image’s “feel” or surface patterns.
Hu Moments provide a set of shape descriptors that remain consistent despite rotations, scaling, or reflections. This allows us to characterize the structural layout of an image’s content.
LBP captures small-scale texture by comparing the intensity of each pixel to its neighbors. This simple, yet powerful approach is robust to illumination changes and helps characterize local texture details.
Scale-Invariant Feature Transform (SIFT) finds keypoints in an image that remain recognizable even when the image is resized, rotated, or viewed from different angles. These keypoints help match images based on distinctive local details.
After the system returns initial search results, users can mark images as relevant or irrelevant. This feedback is then used to adjust the internal representation of the user’s query, guiding the system toward images that better match the user’s criteria. Over multiple rounds, this interactive process fine-tunes the results, improving the precision of the search.
Reference: Salton, G. & Buckley, C. "Improving retrieval performance by relevance feedback." JASIS (1990)
- Python 3.11 or Higher: python.org/downloads
- Git: git-scm.com/downloads
- Virtual Environment (Recommended)
git clone https://github.com/OmarNouih/RelevImageSearch.git
cd RelevImageSearch
python -m venv venv
# Windows:
venv\Scripts\activate
# macOS/Linux:
source venv/bin/activate
pip install --upgrade pip
pip install -r requirements.txt
The project uses the RSSCN7 dataset:
- Visit the RSSCN7 Dataset Repository
- Download or clone it, and place the contents in
RSSCN7-master
within the project root.
python app.py
This creates site.db
and initializes the schema.
python app.py
Open http://127.0.0.1:5000/
in your browser.
- Register/Login: Create an account or log in with existing credentials.
- Upload Images: Add images organized by categories.
- Browse and Search: Initiate a search using a query image.
- Relevance Feedback: Mark results as relevant or irrelevant to refine future searches.
- Feature Visualization: Explore extracted features for deeper insight.
- Endpoint:
/api/descriptor
- Method:
POST
- Request:
{ "image_path": "path/to/image.jpg" }
- Response:
{ "histogram": [/* ... */] }
- Flask, Flask-RESTful, Flask-Login, Flask-Bcrypt, Flask-CORS, Flask-Session, Flask-WTF
- SQLAlchemy
- OpenCV (cv2)
- NumPy
- scikit-learn, scikit-image
- Matplotlib
- tqdm
Install all requirements using:
pip install -r requirements.txt
RelevImageSearch/
├── app.py
├── models.py
├── forms.py
├── requirements.txt
├── RSSCN7-master/
│ ├── Category1/
│ ├── Category2/
│ └── ...
├── features/
├── uploads/
├── flask_session/
├── templates/
│ ├── index.html
│ ├── login.html
│ ├── register.html
│ ├── upload.html
│ ├── category.html
│ ├── search.html
│ └── features.html
├── static/
│ ├── css/
│ ├── js/
│ └── images/
└── README.md
- Fork the repository.
- Create a new branch for your feature.
- Commit and push your changes.
- Open a pull request.
All GitHub docs are open source. See something that's wrong or unclear? Submit a pull request.
© 2024 GitHub, Inc.
Terms | Privacy | Status | Pricing | Expert services | Blog