TextureBasedImageRetriever a Content Based Image Retriever that focuses on texture. It implements the offline phase which is the calulation of descriptors of all images in the datasetn, and the online phase that return the n-similar images from dataset given an input image.
-
python3 should be installed.
-
Installing needed python modules:
pip install -r requirements.txt
To test things, run:
jupyter notebook
Choose then testing.ipynb
OR, you can use it in your script:
- Calculating all descriptors of our dataset:
import cbir
import settings
# TBIR class takes 2 argument:
# * PATH_TO_DATASET
# * PATH_WHERE_TO_SAVE_DESCRPTORS
my_cbir = cbir.TBIR(dataset_dir=settings.DATASET_DIR, descriptors_dir=settings.DESCRIPTORS_DIR))
# calculating the descriptors
my_cbir.offline_phase()
- Retrieving top 'settings.ELITE_NUMBER' similar image for a 'tes_image.jpg':
similar = my_cbir.online_phase("tes_image.jpg")
# showing results
for s in similar:
print("image path: {}, distance: {}".format(s["image_path"], s["distance"]))
- In settings.py file, you can change some entries to fit your needs such as:
- DATASET_DIR
- DESCRIPTORS_DIR
- ELITE_NUMBER : number of best fit images to return in the online_phase
- DEBUG : show extras output