Sign In

Faster Tagging GUI Script

Faster Tagging GUI Script

Sometimes you want to tag the pictures one by one, because your data set is a mixture of several distinct types. For example, I get 3000 minecraft skins from somewhere, and now I want to catergorize them by their eye color. Here I got a script from GPT.

import os
import shutil
from PIL import ImageTk, Image
import tkinter as tk
from tkinter import messagebox

class ImageClassifier:
    def __init__(self, master, img_dir, categories):
        self.master = master
        self.img_dir = img_dir
        self.categories = categories
        self.images = os.listdir(img_dir)
        self.image_index = 0


    def setup_ui(self):
        self.image_label = tk.Label(self.master)

        for category in self.categories:
            button = tk.Button(self.master, text=category, command=lambda cat=category: self.classify_image(cat))


    def load_image(self):
        while self.image_index < len(self.images):
            img_path = os.path.join(self.img_dir, self.images[self.image_index])
            if os.path.isfile(img_path):
                img =
                img = img.resize((512, 512), Image.NEAREST) # adjust image size
                img = ImageTk.PhotoImage(img)
                self.image_label.image = img
                self.image_index += 1
            messagebox.showinfo("Info", "No more images to classify")

    def classify_image(self, category):
        src = os.path.join(self.img_dir, self.images[self.image_index])
        dest_dir = os.path.join(self.img_dir, category)
        os.makedirs(dest_dir, exist_ok=True)
        dest = os.path.join(dest_dir, self.images[self.image_index])

        shutil.move(src, dest)
        self.image_index += 1

if __name__ == "__main__":
    root = tk.Tk()
    app = ImageClassifier(root, "input", 
                          ["red", "blue", "orange", "yellow", "green", "cyan", "purple", "pink", "grey", "black", "white", "brown", "other"])

Feel free to use it. Paste it into a file named then python, and you are ready to go.

Place the data into a folder called "input" and place this script alongside the "input" folder.

You may change the catergories by editing the "app = ImageClassifier" part. It is strongly recommended that you remain an "other" alongside your other options.

Whenever you click a button, that picture will be thrown into the corresponding sub folder like "input/red". If it does not exist, it will automatically create it.