/kmeans

Extremely simple implementation of KMeans clustering algorithm

Primary LanguagePythonMIT LicenseMIT

kmeans

Extremely simple implementation of KMeans clustering algorithm

Usage

First, you create virtual environment and install package. I already tested it and it works well in my environment (Windows 10).

conda create python=3.8 -n kmeans
conda activate kmeans
pip install numpy matplotlib
python kmeans.py

For your information, I attached a help message for better usage.

usage: kmeans.py [-h] [--k K] [--input INPUT]

optional arguments:
  -h, --help     show this help message and exit
  --k K          The number of centroid (default to 50)
  --input INPUT  The filepath for input image (default to os.path.join("res", "input.jpg"))

Input

I just downloaded an image from the image search result in Google with keyword "Detroit become human kara". This image could raise an copyright issue. If it occurs, I will change the other copyright-free image, but for now, I want to keep this image because this image makes me passionate to implement this code.

The original source: https://www.syfy.com/syfywire/video-game-heroine-of-the-month-kara-from-detroit-become-human input

Output

K Result K Result
2 result_2 3 result_3
4 result_4 5 result_5
6 result_6 7 result_7
8 result_8 9 result_9
10 result_10 50 result_50

Contact

Please open an issue or send an e-mail if you have trouble with this code or find a bug.