Skip to content

6six7sven/Image-Sorter-using-CLIP-with-TKinter-GUI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ImageSorter — CLIP-Based Image Organizer with GUI

A desktop tool that uses OpenAI’s CLIP model to automatically classify and organize images into user-defined categories.
Images are assigned to one and only one category folder based on the highest-scoring CLIP similarity.

Includes a full Tkinter GUI for easy use.


✨ Features

  • Organizes only images (.jpg, .jpeg, .png, .gif, .bmp, .tiff, .webp)

  • Uses CLIP (openai/clip-vit-base-patch32) for semantic image understanding

  • Images go to exactly one category

  • Fully custom categories

    • Load from .txt
    • Or enter comma-separated list
  • Dry-run mode for safe previews

  • Move or Copy modes

  • Progress bar + live console output

  • Multi-threaded worker keeps UI responsive

  • Saves CSV log (when not dry-run)

  • Works on Windows / Linux / macOS

  • Demo Tkinter UI Demo


📦 Installation

1. Clone the repository

git clone https://github.com/<your-user>/<your-repo>.git
cd <your-repo>

2. Create a virtual environment

python -m venv .venv

3. Activate the venv (PowerShell)

.\.venv\Scripts\Activate.ps1

If PowerShell blocks scripts:

Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
.\.venv\Scripts\Activate.ps1

4. Install dependencies

pip install -r requirements.txt

▶️ Running the GUI

python organize_images_clip_gui.py

A window will appear with all available options.


🗂 Categories

You can define categories using either method:

Option A — categories.txt

Example:

People
Food
Screenshots
Documents
Pets
Landscapes
Receipts

Load it via Load from File in the GUI.

Option B — Inline (comma-separated)

People, Food, Screenshots, Pets

🛠 How It Works

  1. Recursively scans the chosen root folder for images.

  2. For each category, CLIP evaluates prompts like:

    "a photo of people"
    "a photo of food"
    "a photo of receipts"
    
  3. Picks the highest-probability category if above threshold.

  4. Moves/Copies the image into:

    <target>/<CategoryName>/
    
  5. If no category scores high enough:

    <target>/Uncategorized/
    

📄 Log Output

When not in dry-run mode, saves:

<target>/organize_images_log.csv

Columns include:

  • src
  • dst
  • category
  • score

💻 Requirements

torch>=2.0.0
torchvision>=0.15.0
transformers>=4.30.0
pillow>=9.0.0
tqdm>=4.60.0
pandas>=1.3.0
typing-extensions

If you want GPU acceleration, install PyTorch with CUDA via: https://pytorch.org


📁 Folder Structure Example

/
├── organize_images_clip_gui.py
├── requirements.txt
├── categories.txt
└── README.md

🧪 Tips

  • Enable dry-run first to verify.
  • Use cuda device for faster sorting (if available).
  • Good threshold values: 0.20–0.35.

About

A desktop tool that uses OpenAI’s CLIP model to automatically classify and organize images into user-defined categories.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages