|
1 | 1 | # Tasnif
|
| 2 | + |
| 3 | +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. |
| 4 | + |
| 5 | +## Features |
| 6 | + |
| 7 | +- Generate embeddings for images using a pre-trained model. |
| 8 | +- Dimensionality reduction using PCA to enhance clustering performance. |
| 9 | +- Clustering of images into user-specified classes with K-means. |
| 10 | +- Visualization support by creating image grids for each cluster. |
| 11 | +- Efficient image reading and preprocessing utilities. |
| 12 | + |
| 13 | +## Installation |
| 14 | + |
| 15 | +To install Tasnif, you need Python 3.6 or later. Clone this repository to your local machine and install the required dependencies: |
| 16 | + |
| 17 | +```bash |
| 18 | +pip install tasnif |
| 19 | +``` |
| 20 | + |
| 21 | +## Usage |
| 22 | + |
| 23 | +Import `Tasnif` and initialize it with the desired number of classes, PCA dimensions, and whether to use GPU: |
| 24 | + |
| 25 | +```python |
| 26 | +from tasnif import Tasnif |
| 27 | + |
| 28 | +# Initialize Tasnif with 5 classes, PCA dimensions set to 16, and GPU usage |
| 29 | +classifier = Tasnif(num_classes=5, pca_dim=16, use_gpu=False) |
| 30 | +``` |
| 31 | + |
| 32 | +Read the images from a directory, calculate the embeddings, PCA, and perform K-means clustering: |
| 33 | + |
| 34 | +```python |
| 35 | +# Read images from a specified directory |
| 36 | +classifier.read('path/to/your/images') |
| 37 | + |
| 38 | +# Calculate embeddings, PCA, and perform clustering |
| 39 | +classifier.calculate() |
| 40 | +``` |
| 41 | + |
| 42 | +Finally, export the clustered images and visualization grids to a specified directory: |
| 43 | + |
| 44 | +```python |
| 45 | +# Export clustered images and grids |
| 46 | +classifier.export('path/to/output') |
| 47 | +``` |
| 48 | + |
| 49 | +## Contributing |
| 50 | + |
| 51 | +Contributions to `Tasnif` are welcome! Please fork the repository and submit a pull request with your proposed changes. |
| 52 | + |
| 53 | +## License |
| 54 | + |
| 55 | +Tasnif is released under the MIT License. See the [LICENSE](LICENSE) file for more details. |
0 commit comments