Skip to content

Python app created with the purpose of speeding up and greatly facilitating the task of cleaning and adjusting Booru-style tags, aimed at fine-tuning the Stable Diffusion model.

Notifications You must be signed in to change notification settings

sangoi-exe/das-EzBooruTagEditor

Repository files navigation

das-EzBooruTagEditor

Screenshot

Introduction

This application is designed to accelerate and simplify the management of Booru-style tags, primarily for fine-tuning Stable Diffusion models where tags play a crucial role, often more significant than the actual image dataset.

Installation

You can set up das-EzBooruTagEditor on your system in two ways:

Option 1: Using the Executable

  • Download the Executable: Go to the Releases page and download the latest .exe file.
  • Run: Double-click the downloaded file to run the application. No installation or Python environment required.

Option 2: Cloning the Repository

  • Clone the Repository: Run git clone https://github.com/DevArqSangoi/das-EzBooruTagEditor.git to clone the repository to your local machine.
  • Navigate to the Directory: Change to the directory where the repository was cloned. E.g., cd das-EzBooruTagEditor.
  • Install Dependencies: Install the Pillow library by running pip install Pillow in your command line. This is necessary for image processing.
  • Run the Script: Execute the script with python EzBooruTagEditor.py.

Operation Guide

Caution

❗BACKUP YOUR TAG FILES BEFORE USING THIS APP❗

Warning

❗BACKUP YOUR TAG FILES BEFORE USING THIS APP❗

Starting Up

  • Select Folder: From the home screen, choose the folder containing images and their respective text files (.txt). Choose Dir
  • Navigation: Navigate through images using (in the order of navigation shown in the gif) mouse scroll with the cursor on the image frame, by clicking in the list, with the keyboard arrows (up and down), or by using the buttons on the interface.
    Navigation

Managing Tags

  • Viewing and Selecting Tags:
    • The left-hand list populates with text files having corresponding images.
    • Selecting a list item displays the image and tags.
  • Editing Tags:
    • Delete: Click a tag once to select, and again to delete. Delete
    • Undo Deletion: Click 'Undo' or use 'Ctrl+Z'.
      Undo
    • Add Tag: Enter the tag in the text box and press "Add Tag" or "Enter". Unique tags are added to a unique list; similar tags are grouped. Add
    • Tag Info: Right-clicking on a tag fetches its description from the Danbooru API, displayed in a dialog box. This feature requires a Danbooru account. A popup providing guidance for account creation and API key generation will appear if a user attempts to use this feature without having configured the API key and login.
      Add
    • Customizing Tag Grouping:
      • Similar tags can be grouped by editing the config.json file using the format "words": ["gloves", "hair", "footwear"].
      • This file is automatically generated after running the program and viewing the first image. Users can add or modify the listed words to define their own tag groupings.

Saving

  • Save Changes: Press 'Save' or use 'Ctrl+S'.

❗Important Notes

  • ❗Backup First: Always back up your tag files before using this app. This step is crucial to protect your data against any unintended changes.
  • Non-Real-Time Editing: Changes are not real-time; navigate away to discard large mistakes.
  • Save Before Switching: Unsaved changes are lost when switching images. Future updates may include memory-based temporary saving.

Future Plans

I plan to introduce memory-based modifications in the app to prevent the loss of unsaved changes when switching between images.

Changelog

[2023-12-02]

Bug Fix

  • Duplicate Tags: Fixed a major bug that led to inconsistencies in saving and displaying tags when duplicate entries were present in the txt file.

New Feature

  • Remove Duplicates: Added the ability to remove duplicate tags effortlessly. To use this feature, simply click on 'Remove Duplicates' in the interface.

Improvement

  • Tag list update: Deleting a tag no longer updates the tag list (as it's not necessary), making tag adjustment way more smoth and comfortable.

[2023-11-25]

Bug Fix

  • Token Deletion Bug: Addressed a major bug where the token delete function stopped working if a new tag was added while a token was marked for deletion.

[2023-11-23]

Bug Fixes

  • Interface problem: Fixed a minor bug in the interface, identified by @Nenotriple, where resizing the interface horizontally to a smaller size, while displaying an image with a landscape aspect ratio, caused the image to disappear and trigger an error in the 'resize_image' function.

[2023-11-22]

Again, special thanks to @Nenotriple for the valuable contributions in testing the application and pinpointing crucial improvements and bugs.

New Features

  • Tag Description on Right-Click: Implemented a feature where right-clicking on a tag fetches its description from the Danbooru API, displayed in a dialog box. This feature requires a Danbooru account. A popup providing guidance for account creation and API key generation will appear if a user attempts to use this feature without having configured the API key and login.
  • Save Confirmation Alert: Added an alert confirmation when using the save function to verify successful activation.
  • Console Log for Loaded Images and Tag Files: Included logging in the console about the currently selected image and tag file for verification purposes.
  • Image Name Display: Introduced a text box below the tags to display the name of the currently opened image, adding another layer of verification for image and tag file matching.
  • Directory Display in Window Title: The program's window title now includes the name of the selected directory, enhancing user awareness of the current working directory.

Bug Fixes

  • Focus Issue in Tag Entry: Fixed a bug where double-clicking the tag entry field caused the focus to shift away from the listbox, clearing the selection. #3
  • Filename and Image/Tag Pairing: Resolved an issue where the wrong filename was sometimes incorrectly associated with the displayed image/tags. This fix ensures that the correct img-txt pair is loaded and the correct txt file is saved. #2
  • Refactoring of Tag Management Functions: Refactored the add_tag and rearrange_tags functions to address inconsistencies in tag classification, enhancing the reliability and accuracy of the tagging process.

[2023-11-21]

A special thanks to @Nenotriple for their assistance in testing the app and identifying key improvements and bugs to be addressed. #1

New Implementations

  • Manual Tag Grouping with JSON Configuration: Transitioned from the automatic grouping of tags based on common words to a user-driven approach using a JSON file. Users now have direct control over tag associations, defining their own groupings in the config.json. This update eliminates the program's previous behavior of automatic tag duplication, offering a tailored tagging experience.

  • Enhanced Alphanumeric Sorting Logic: Improved the file sorting algorithm to use natural alphanumeric ordering, ensuring that filenames are sorted in an intuitive sequence (e.g., '2' comes before '10').

  • WebP Image Support: Added support for WebP images. The application now recognizes .webp along with other common image formats (.png, .jpg, .jpeg, .gif).

  • UI Enhancement for Token Deletion: Updated the color for the delete token highlight, enhancing visual clarity and user experience.

Bug Fixes

  • Interface Clearing on New Directory Selection: Corrected a minor bug where previously selected images and tags were persisting after a new directory was chosen. Now, the interface is cleared, ensuring a fresh start with each directory change.

  • Improved Choose Directory Handling: Addressed an issue where canceling out of the "Choose Directory" dialog would lead to a loss of reference to the currently selected directory. Previously, this would leave the file list populated but non-functional. The program now retains the reference to the current directory unless a new one is explicitly chosen, ensuring continuous access to the file list.

  • Duplicate Tag Handling: Fixed a major bug where duplicate tags shown in the UI were being saved as duplicates in the text file. This fix prevents the unintended duplication of tags in the saved files.

  • Token Deletion Bug: Addressed a major bug where the token delete function stopped working if the user selected a token but moved to the next/previous image without deleting it.


License

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

CC BY-NC-SA 4.0

CC BY-NC-SA 4.0

About

Python app created with the purpose of speeding up and greatly facilitating the task of cleaning and adjusting Booru-style tags, aimed at fine-tuning the Stable Diffusion model.

Topics

Resources

Stars

Watchers

Forks