https://github.com/seanghay/clipsort
Group images by provided labels using OpenAI/CLIP
https://github.com/seanghay/clipsort
clip huggingface openai openai-clip openclip transformers vision-transformer
Last synced: 3 months ago
JSON representation
Group images by provided labels using OpenAI/CLIP
- Host: GitHub
- URL: https://github.com/seanghay/clipsort
- Owner: seanghay
- License: apache-2.0
- Created: 2023-06-10T08:00:33.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-06-10T10:44:13.000Z (over 2 years ago)
- Last Synced: 2025-06-09T10:04:14.920Z (4 months ago)
- Topics: clip, huggingface, openai, openai-clip, openclip, transformers, vision-transformer
- Language: Python
- Homepage:
- Size: 11.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
## `clipsort` - Organize image files with zero-shot classification
Categorize photos into it corresponding provided label with [openai/clip-vit-base-patch16](https://huggingface.co/openai/clip-vit-base-patch16).
### Basic Usage
Create a new Anaconda environment
```shell
conda create -n clipsort python==3.8
conda activate clipsort
pip install -r requirements.txt
```Run the inference
```shell
python clipsort.py data/*.jpg --output ./output/ --labels food menu logo
```Result
```
output
├── food
│ ├── image-11.jpg
│ ├── image-3.jpg
│ ├── image-4.jpg
│ ├── image-5.jpg
│ ├── image-6.jpg
│ ├── image-7.jpg
│ ├── image-8.jpg
│ └── image-9.jpg
├── logo
│ ├── image-10.jpg
│ └── image-2.jpg
└── menu
└── image-1.jpg
```## Options
```
usage: clipsort [-h] [-o OUTPUT] -l LABELS [LABELS ...] [-w] [-t TAKE] [-m MODEL] files [files ...]Sort unstructured photos with CLIP
positional arguments:
files Path to filesoptional arguments:
-h, --help show this help message and exit
-o OUTPUT, --output OUTPUT
Output folder
-l LABELS [LABELS ...], --labels LABELS [LABELS ...]
-w, --overwrite Overwrite exsting file in the output dir
-t TAKE, --take TAKE Number of final labels to save
-m MODEL, --model MODEL
```