Unveiling the Power of DELF and TensorFlow Hub in Image Analysis: A Comprehensive Exploration

Shuvam Das
4 min readMar 24, 2024

--

Well, many people might not know about DELF, but it is an amazing tool for image retrieval and feature extraction.

There are many large datasets available on the internet like the Oxford dataset, and Google Landmark dataset that people want to explore but they don't get a proper pipeline for their explorations.

This article is about how I used DELF for my own dataset.

Introduction:

In today’s data-driven world, the ability to extract meaningful insights from images is paramount. Google’s Deep Local Features (DELF) and TensorFlow Hub offer a compelling duo that revolutionizes image analysis. In this article, lets embark on a comprehensive journey through the realms of image retrieval, feature extraction, and bounding box extraction, leveraging the prowess of DELF and TensorFlow Hub. Our focal point is the illustrious Oxford dataset, a treasure trove of diverse visual data. It's an amazing library containing all the pre-trained models and amazing features to make your image extraction task much much easier. Enough of bookish language crap let's get into the main thing.

Understanding DELF and TensorFlow Hub:

To embark on this journey, it’s crucial to grasp the essence of DELF and TensorFlow Hub. DELF, short for Deep Local Features, represents a pinnacle in local feature extraction from images. DELF needs some pre-requirements. Sometimes it gets too hard to install DELF in your local computers because of requirements issues. So it's better to run it in Colab where all the library-related issues are solved automatically. TensorFlow Hub, on the other hand, serves as a repository of pre-trained machine learning models, facilitating seamless integration of machine learning capabilities into diverse applications. After you finish setting up the DELF and the Tensorflow models sometimes you will have to modify the folders accordingly to make the code run properly. Mostly everything happens inside the models/research/delf/delf/python/examples folder. So make sure to look into it before being the dark mode coder.

The Journey Begins: Image Retrieval

Our voyage commences with image retrieval, a fundamental task in image analysis. Leveraging the capabilities of DELF and TensorFlow Hub, we set out to retrieve similar images based on a query image. The Oxford dataset, renowned for its extensive collection of images with rich annotations, serves as our playground.

At the outset, we load the DELF model from TensorFlow Hub, which serves as our cornerstone for feature extraction and comparison across images. Armed with the DELF model, we embark on feature extraction, extracting descriptors from both the query image and the dataset images. These descriptors lay the groundwork for computing similarities and retrieving similar images.

Diving Deeper: Feature Extraction and Bounding Box

The output image shows similarities between the images.

Beyond image retrieval, DELF empowers us to extract rich visual features from images, unlocking deeper insights into visual content. There is an inbuilt image-extracting file named Extract_features.py. You can create a list with the subset of images and name it list.txt and then run it with the extract_features.py and it will create a folder containing the output of the extracted features. The extracted features encapsulate the essence of visual data, serving as invaluable inputs for tasks such as image classification and object detection. It will take time according to your GPU system. By harnessing the power of DELF, we delve into feature extraction, unraveling the intricate nuances of visual data within the Oxford dataset.

The Image after passing through box extraction. The bounding box is created around the image.

Another feature that the delf provides is box_io.py. Basically, it's a file inside the extract_boxes.py. You can pass the same list of images here to retrieve a bounding box on the respective images. I modified the box_io.py for my own use to retrieve the coordinates of the bounding box in a text file to use it for other image matching purposes like using YOLOv5 (will discuss it in some other article). It also creates a folder containing the box information and the bounded box images.

Conclusion:

DELF and TensorFlow Hub stand as pillars in the realm of computer vision, offering a potent arsenal for image analysis. Through our expedition, I’ve witnessed the transformative power of DELF and TensorFlow Hub in tasks such as image retrieval, feature extraction, and bounding box extraction. Whether it’s unraveling the intricacies of visual data or unlocking hidden insights within images, DELF and TensorFlow Hub serve as steadfast companions, guiding us through the labyrinth of image analysis with unparalleled precision and efficacy. This was just a short introduction to DELF and its power. I might write an article about my code with DELF and explain it, and how I used DELF for my purpose.

If you want to know anything about the code, how to install delf, any problems with datasets, or any modified features do feel free to contact me.

--

--