Skip to main content

A simple library for unsupervised image clustering

Project description

accessibility text

Tasnif is a Python package designed for clustering images into user-defined classes based on their visual content. It utilizes deep learning to generate image embeddings, Principal Component Analysis (PCA) for dimensionality reduction, and K-means for clustering. Tasnif supports processing on both GPU and CPU, making it versatile for different computational environments.

Features

  • Generate embeddings for images using a pre-trained model.
  • Dimensionality reduction using PCA to enhance clustering performance.
  • Clustering of images into user-specified classes with K-means.
  • Visualization support by creating image grids for each cluster.
  • Efficient image reading and preprocessing utilities.

Installation

To install Tasnif, you need Python 3.6 or later. Clone this repository to your local machine and install the required dependencies:

pip install tasnif

Usage

Import Tasnif and initialize it with the desired number of classes, PCA dimensions, and whether to use GPU:

from tasnif import Tasnif

# Initialize Tasnif with 5 classes, PCA dimensions set to 16, and GPU usage
classifier = Tasnif(num_classes=5, pca_dim=16, use_gpu=False)

Read the images from a directory, calculate the embeddings, PCA, and perform K-means clustering:

# Read images from a specified directory
classifier.read('path/to/your/images')

# Calculate embeddings, PCA, and perform clustering
classifier.calculate()

Finally, export the clustered images and visualization grids to a specified directory:

# Export clustered images and grids
classifier.export('path/to/output')

To-Do

  • Prevent calculation if there is no image read (PCA & k-means)
  • Export embeddings
  • Make model independent from img2vec
  • Separate cpu and gpu installation and catch gpu errors

Contributing

Contributions to Tasnif are welcome! Please fork the repository and submit a pull request with your proposed changes.

License

Tasnif is released under the MIT License. See the LICENSE file for more 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

tasnif-0.1.11.tar.gz (7.6 kB view details)

Uploaded Source

File details

Details for the file tasnif-0.1.11.tar.gz.

File metadata

  • Download URL: tasnif-0.1.11.tar.gz
  • Upload date:
  • Size: 7.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.10.6

File hashes

Hashes for tasnif-0.1.11.tar.gz
Algorithm Hash digest
SHA256 675b09c3726b7fd132e3c3006cb093382468839b9d68114d7b1c1952901192e2
MD5 e3bc597670c072714c35f1b4ab3c1dec
BLAKE2b-256 28183bccb2935f53bf422e54d8de9dbe2de3e89563aaf0417300e2930f8932f9

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