A web-based interface for Content-Based Image Retrieval. Upload a query image and find similar images using various feature extraction methods.
- Python 3.8+ —
python --version - CMake — Download or
brew install cmake(macOS) /sudo apt install cmake(Linux) - OpenCV — Download (Windows) or
brew install opencv(macOS) /sudo apt install libopencv-dev(Linux) - C++ Compiler — Visual Studio (Windows), Xcode (macOS), or GCC (Linux)
You can watch the demo of this project at the link below:
Demo Video:
https://drive.google.com/file/d/1NYAok6uiD5psRPR5hImfyYbnEgWzRcQx/view?usp=sharing
Double-click setup_and_run.bat or run via command prompt:
git clone https://github.com/dkumar247/cbir.git
cd cbir
setup_and_run.batgit clone https://github.com/dkumar247/cbir.git
cd cbir
chmod +x setup_and_run.sh
./setup_and_run.shThe script will:
- Build the C++ backend (using CMake)
- Install Python dependencies (Flask)
- Start the web server at http://localhost:5001
- Click "Choose Image" and select any
.jpgimage - Select a feature extraction method from the dropdown
- Set the number of results (1–20)
- Click "Search Similar Images"
| Method | Description |
|---|---|
| Baseline (7×7) | Center patch comparison |
| RGB Histogram | Global color distribution |
| Multi-Histogram | Top/bottom spatial color matching |
| Texture + Color | Sobel gradients + RGB histogram |
| DNN Embedding | ResNet18 semantic similarity |
All paths and settings are in config.py. By default, relative paths are used so everything works out of the box.
cbir/
├── setup_and_run.sh # ← Run this to start
├── config.py # All configurable settings
├── app.py # Flask backend
├── templates/
│ └── index.html # Web UI
├── cpp_src/ # C++ CBIR engine (built automatically)
├── data/ # Image database + pre-computed features
└── requirements.txt # Python dependencies
| Problem | Solution |
|---|---|
| Problem | Solution |
| --------- | ---------- |
cmake: command not found |
Install CMake and ensure it's in your system PATH. |
OpenCV not found (Windows) |
Set OpenCV_DIR environment variable to your opencv/build folder or run CMake with -DOpenCV_DIR="C:/path/to/opencv/build". |
dll missing (Windows) |
Add OpenCV bin (containing DLLs) to PATH or copy DLLs next to the executable. |
flask not found |
Run pip install -r requirements.txt. |
| Port 5001 in use | (macOS/Linux) lsof -ti:5001 | xargs kill (Windows) Use Task Manager to kill Python processes. |
Deepanshu Kumar and Prathmesh Barapatre