Visualize Image Clustering

franky
2 min readMar 30, 2018

--

My last post “Using Keras’ Pre-trained Models for Feature Extraction in Image Clustering” described a study about using deep-learning image-recognition models for feature extraction in clustering a set of dog/cat images. One interesting question is how can we visualize the results in two dimensional space. Here is how it looks like.

Figure 1. Cosine Similarity in Image Clustering
Figure 2 and Figure 3 show pictures associated with points.

Some notes on designing and implementing our solution.

  • Keras’ pre-trained model ResNet50 is used for feature extraction, and Scikit-Learn’s clustering algorithm kMeans is used for feature clustering. [ref]
  • Figure 1 illustrates cosine similarity between the feature of an image and the center of cluster 1 or the center of cluster 2, where cosine similarity is implemented by using SciPy. [ref]
  • In Figure 1, whether a point is in red or is in blue depends on the label predicted by kMeans in Scikit-Learn, not on the ground truth.
  • Figure 2 and Figure 3 are interactive diagrams showing a dog image or a cat image upon the mouse hovering over a point. The effect is implemented by using Offsetbox in Matplotlib. [ref]

Here are some pictures around the boundary of two clusters.

Figure 4. Is the wolfdog licking a kitty?
Figure 5. Who put this picture into the dataset ?!

Alright … love the data … 😄

Here are some pictures around the edge of a cluster.

Figure 6. Free the Dogs!
Figure 7. Using Euclidean Distance rather than Cosine Similarity

Hate the pets in cage … 😡

Any comments from data scientists or pet lovers?

--

--

franky
franky

Responses (3)