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(dotsize=50)
# Plot dendrogram
cl.dendrogram()
# Plot clustered images
cl.plot(ncols=5)

# Predict
results_find = cl.find(path_to_imgs[0:5], k=None, alpha=0.05)
cl.plot_find()
cl.scatter()

Make prediction for unseen input image.

# Predict
results_find = cl.find(path_to_imgs[0:5], alpha=0.05)
cl.plot_find()
cl.scatter()

images with faces to cluster.

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.2.0.tar.gz (22.9 kB view details)

Uploaded Source

Built Distribution

clustimage-1.2.0-py3-none-any.whl (22.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: clustimage-1.2.0.tar.gz
  • Upload date:
  • Size: 22.9 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.2.0.tar.gz
Algorithm Hash digest
SHA256 7be551ee6973da9726f287c4201ee0ba6d1210a49440b0cb03bfa96a053f8031
MD5 dd72dda4911c35051380baaad3be9177
BLAKE2b-256 fc71ac34628efb9fc8c24775eff8811b9c97a53284cbbb7d0516913f6c960cf5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: clustimage-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 22.5 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.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 066e3a5a9a21c51401ef799371cd26614bb57992ad43dc551071b8909b067d4f
MD5 952ddaad2c45b334f00ce732d77d7b69
BLAKE2b-256 a662489347f74a6bd274aa3ccaa7e27a84ef0c28df4007fbf4b2640d8a8ecb38

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