Coder Social home page Coder Social logo

rohanbaisantry / image-clustering Goto Github PK

View Code? Open in Web Editor NEW
44.0 1.0 27.0 42 KB

This is a simple image clustering algorithm which uses KMeans for clustering and performs 3 types of vectorization using vgg16, vgg19 and resnet50 using the weights from ImageNet

Python 100.00%
python kmeans-clustering image-clusterization machine-learning deep-learning convolutional-neural-networks

image-clustering's Introduction

Image-Clustering using KMeans (A Python3 implementation)

This is a simple unsupervised image clustering algorithm which uses KMeans for clustering and Keras applications with weights pre-trained on ImageNet for vectorization of the images.

A folder named "output" will be created and the different clusters formed using the different algorithms will be present.

Change the following variables(present in the main() function) as per your convinience:

  1. number_of_clusters - The number of clusters to be created by the clustering algorithm. (default is 10)
  2. data_path - This is the path of the folder that contans the different images that you want to pass to the algorithm.
  3. max_examples - The max number of examples to be used for the clustering (if None, all the images in the data_path folder will be used)
  4. use_imagenets - choose which keras application to use. (Choose from: "Xception", "VGG16", "VGG19", "ResNet50", "InceptionV3", "InceptionResNetV2", "DenseNet", "MobileNetV2" and "False". If False, the image will be passed as is to the clustering algorithm)
  5. use_pca - choose whether to use PCA for dimentionality reduction. (choose betwwen between "True" and "False". If use_imagenets=False, then use_pca will automatically be set to False as well)

Python Modules used:
-Keras
-Theano (as backend for keras)
-os
-sys
-random
-cv2 (openCV)
-numpy
-sklearn (scikit-learn for KMeans and PCA)
-shutil

To Run: "python image_clustering.py"

Pipeline:
step 1: Set the different parameters for the model. (The Variables mentioned above)
step 2: Initialize an object of the class "image_clustering" with the parameters set in the previous step.
step 3: Call the class's load_data() function.
step 4: Call the class's get_new_imagevector() function.
step 5: Call the clustering() function.

image-clustering's People

Contributors

rohanbaisantry avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

image-clustering's Issues

Error during prediction

There is an error thrown during prediction

pred = model1.predict(self.images)
the error is
ValueError: Error when checking input: expected input_1 to have 4 dimensions, but got array with shape (500, 150528)
I think it's handling all images as one

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.