{"id":21474643,"url":"https://github.com/pabsan-0/image-clustering","last_synced_at":"2026-04-17T00:02:25.691Z","repository":{"id":175790443,"uuid":"504545340","full_name":"pabsan-0/image-clustering","owner":"pabsan-0","description":"K-means clustering of images with VGG18 featurizer","archived":false,"fork":false,"pushed_at":"2023-06-19T08:12:17.000Z","size":3307,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-17T07:44:55.091Z","etag":null,"topics":["opencv","pytorch","repos-ml","sklearn"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pabsan-0.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-06-17T13:29:44.000Z","updated_at":"2024-08-30T08:46:27.000Z","dependencies_parsed_at":null,"dependency_job_id":"70476140-35b7-4a0d-88bf-005bace6bdf3","html_url":"https://github.com/pabsan-0/image-clustering","commit_stats":null,"previous_names":["pabsan-0/image-clustering"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/pabsan-0/image-clustering","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pabsan-0%2Fimage-clustering","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pabsan-0%2Fimage-clustering/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pabsan-0%2Fimage-clustering/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pabsan-0%2Fimage-clustering/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pabsan-0","download_url":"https://codeload.github.com/pabsan-0/image-clustering/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pabsan-0%2Fimage-clustering/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31909235,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-16T18:22:33.417Z","status":"ssl_error","status_checked_at":"2026-04-16T18:21:47.142Z","response_time":69,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["opencv","pytorch","repos-ml","sklearn"],"created_at":"2024-11-23T10:24:24.328Z","updated_at":"2026-04-17T00:02:25.658Z","avatar_url":"https://github.com/pabsan-0.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Image clustering\n\nSimple K-means clustering of VGG-16 featurized images.\n\n\n![image](cache/clusters.png)\n\n## Requirements\n\n- Install through pip: `$ pip3 install -r requirements.txt`\n- The following are also needed, mind that you have no version collisions:\n    - Pytorch\n    - Opencv\n\nOptionally, use Docker to run a `pytorch` container: `docker compose run pytorch`. You still need to install deps from `requirements.txt`.\n\n## Usage\n\n- Run featurization \u0026 clustering with: \n```\n$ python3 main.py --n-clusters 5 --no-use-cache samples/*.jpg\n```\n- An image-cluster preview is stored in `cache/clusters.png`.\n- Find the output in `cache/groups/*.txt` as path lists of your files by cluster. Then you can do some stuff like:\n```\n# Verify listed items exist\ncat cache/groups/0.txt | xargs ls\n\n# Copy/link image to pwd\ncat cache/groups/0.txt | xargs cp -t .\ncat cache/groups/0.txt | xargs realpath | xargs ln -st .\n```\n\nBy default, intermediate files containing the list of input images and their features will be stored on disk. If trying to re-featurize the very same images, cached features will be loaded to save time.\n\n## Scripts\n\n```\n$ python3 main.py --help \nusage: main.py [-h] [-n N_CLUSTERS] [--no-save-cache] [--no-use-cache] [--no-preview] ...\n\npositional arguments:\n  images                Images to cluster, accepts a glob\n\noptional arguments:\n  -h, --help            show this help message and exit\n  -n N_CLUSTERS, --n-clusters N_CLUSTERS\n                        K means number of clusters\n  --no-save-cache       Do not cache features\n  --no-use-cache        Do not load features from cache\n  --no-preview          Do not build a preview image\n```\n\n\n## Known issues\n\n- `RuntimeError: CUDA error: CUBLAS_STATUS_ALLOC_FAILED when calling 'cublasCreate(handle)'`\n    - Random error, just rerun\n    - If persisting, try decreasing batch size in the dataloader func\n\n\n## Diving deeper\n\n- https://datagen.tech/guides/computer-vision/vgg16/\n- https://scikit-learn.org/stable/modules/generated/sklearn.cluster.KMeans.html\n- https://scikit-learn.org/stable/auto_examples/cluster/plot_kmeans_silhouette_analysis.html","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpabsan-0%2Fimage-clustering","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpabsan-0%2Fimage-clustering","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpabsan-0%2Fimage-clustering/lists"}