Skip to main content

Python package clustimage is for unsupervised clustering of images.

Project description

clustimage

Python PyPI Version License Github Forks GitHub Open Issues Project Status Sphinx Downloads Downloads BuyMeCoffee

  • clustimage is a python package for unsupervised clustering of images.

Installation

  • Install clustimage from PyPI (recommended). clustimage is compatible with Python 3.6+ and runs on Linux, MacOS X and Windows.
  • A new environment can be created as following:
conda create -n env_clustimage python=3.8
conda activate env_clustimage
  • Install from pypi
pip install -U clustimage

Import the clustimage package

from clustimage import Clustimage

Simple example using data-array as an input.

# Load library
import matplotlib.pyplot as plt
from clustimage import Clustimage
# init
cl = Clustimage()
# Load example digit data
X = cl.import_example(data='digits')

print(X)
# Each row is an image that can be plotted after reshaping:
plt.imshow(X[0,:].reshape(8,8), cmap='binary')
# array([[ 0.,  0.,  5., ...,  0.,  0.,  0.],
#        [ 0.,  0.,  0., ..., 10.,  0.,  0.],
#        [ 0.,  0.,  0., ..., 16.,  9.,  0.],
#        ...,
#        [ 0.,  0.,  0., ...,  9.,  0.,  0.],
#        [ 0.,  0.,  0., ...,  4.,  0.,  0.],
#        [ 0.,  0.,  6., ...,  6.,  0.,  0.]])
# 
# Preprocessing and feature extraction
results = cl.fit_transform(X)

# Scatter
cl.scatter()
# Plot dendrogram
cl.dendrogram()
# Plot the clustered images
cl.plot(cmap='binary')

images with flowers to cluster.

# Load library
from clustimage import Clustimage
# init
cl = Clustimage(method='pca', embedding='tsne')
# load example with flowers
path_to_imgs = cl.import_example(data='flowers')
# Preprocessing and feature extraction
results = cl.fit_transform(path_to_imgs, min_clust=10)
# Scatter
cl.scatter(dot_size=50)
# Plot dendrogram
cl.dendrogram()
# Plot clustered images
cl.plot(ncols=5)

# Predict
results_predict = cl.predict(path_to_imgs[0:5], k=None, alpha=0.05)
cl.plot_predict()
cl.scatter()

Make prediction with unknown input image.

# Predict
results_predict = cl.predict(path_to_imgs[0:5], alpha=0.05)
cl.plot_predict()
cl.scatter()

Make prediction with unknown input image.

from clustimage import Clustimage
# Init
cl = Clustimage(method='pca', grayscale=True, params_pca={'n_components':14})
# Load example with faces
pathnames = cl.import_example(data='faces')
# Detect faces
face_results = cl.detect_faces(pathnames)
# Cluster
results = cl.fit_transform(face_results['facepath'])

# Plot faces
cl.plot_faces()
# Dendrogram depicts the clustering of the faces
cl.dendrogram()

# Make various other plots
cl.scatter()
# Make plot
cl.plot(ncols=2, show_hog=True)

References

Citation

Please cite in your publications if this is useful for your research (see citation).

Maintainers

Contribute

  • All kinds of contributions are welcome!
  • If you wish to buy me a Coffee for this work, it is very appreciated :)

Licence

See LICENSE for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

clustimage-1.0.0.tar.gz (19.3 kB view details)

Uploaded Source

Built Distribution

clustimage-1.0.0-py3-none-any.whl (18.9 kB view details)

Uploaded Python 3

File details

Details for the file clustimage-1.0.0.tar.gz.

File metadata

  • Download URL: clustimage-1.0.0.tar.gz
  • Upload date:
  • Size: 19.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.5.0 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.12

File hashes

Hashes for clustimage-1.0.0.tar.gz
Algorithm Hash digest
SHA256 1b01cf8e50a04d8d26a69e6eb02f8764a8b8d8ab0c11cc7119e7e851d445110e
MD5 31c15e54d73c4fcb085878a6f30ae726
BLAKE2b-256 431d1ae1d87582326b4154a9dda8ffd894a509a67b4ba40a9c456dc78a36cbde

See more details on using hashes here.

File details

Details for the file clustimage-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: clustimage-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 18.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.5.0 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.12

File hashes

Hashes for clustimage-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cab98ba4818eb8133773fdc8524e72ddd4b3a7341f666ae6b193bad1bc8ee238
MD5 774a8bd7eaba07c8ad7edb7324ddd43f
BLAKE2b-256 b5c9a51224d34a47fa6f05058bf806022295fa4265bac5ee71532c004f425a52

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page