Giter Site home page Giter Site logo

devarqsangoi / das-ezboorutageditor Goto Github PK

View Code? Open in Web Editor NEW
10.0 10.0 0.0 114.41 MB

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.

Python 0.89% TeX 42.71% HTML 56.40%
booru stable-diffusion

das-ezboorutageditor's People

Contributors

devarqsangoi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

das-ezboorutageditor's Issues

Updated! - Some suggestions and bugs

Text files should have logical sorting of filenames. So 2 appears before 10, and 4 doesn't appear after 30, etc. You can see this issue in your preview.png image.

webp image support. for img_ext in [".png", ".jpg", ".jpeg", ".gif", ".webp"]:

Maybe use a more desaturated color for the delete token highlight. Something like "#ffcac9"

Minor bug: The previously selected image and tags are still displayed when selecting a new directory.
You could fix this by auto-selecting the first img-txt pair when choosing a directory.

Minor bug: Selecting a folder, then clicking "Choose Directory" and not selecting a file path results in the img-txt pairs being selectable, but tokens no longer show up.

Major bug: Duplicate tags shown in the ui are being saved to the text file as duplicate tags.

This first image shows the tags and the raw text file. As you explained, duplicate tokens are displayed for ease of analysis, that's not the issue.
Raw_Before_Saving

In the second image all I did was click save. This caused the duplicate tokens displayed in the ui to be written to the text file. It also repositioned the token order, but that's pretty minor.
After_clicking_save

Oddly, I had to delete "long hair" twice with 4 clicks.

Major bug: If the user selects a token but doesn't click again to delete it and instead goes to the next/prev image, the token delete function stops working. This is the resulting error when clicking on another token.


Exception in Tkinter callback
Traceback (most recent call last):
  File "C:\Users\egegi\AppData\Local\Programs\Python\Python310\lib\tkinter\__init__.py", line 1921, in __call__  
    return self.func(*args)
  File "C:\Users\egegi\Downloads\EzBooruTagEditor.py", line 273, in <lambda>
    tag_label.bind("<Button-1>", lambda event, t=tag, tl=tag_label: self.on_click(t, tl))
  File "C:\Users\egegi\Downloads\EzBooruTagEditor.py", line 389, in on_click
    self.currently_marked_tag.config(relief="raised", bg=self.currently_marked_tag.original_bg)
  File "C:\Users\egegi\AppData\Local\Programs\Python\Python310\lib\tkinter\__init__.py", line 1675, in configure 
    return self._configure('configure', cnf, kw)
  File "C:\Users\egegi\AppData\Local\Programs\Python\Python310\lib\tkinter\__init__.py", line 1665, in _configure
    self.tk.call(_flatten((self._w, cmd)) + self._options(cnf))
_tkinter.TclError: invalid command name ".!frame.!frame3.!frame.!frame.!frame3.!label3"

Text and image association bug

The wrong filename is sometimes being incorrectly associated with the image/tags displayed. However, the correct img-txt pair is being loaded and the correct txt file is being saved.

1

2

3

Here are the image and text files used in this test.
test.zip

The issue appears to be in the show_file_content function. Because the order of files in the listbox and the order of files in the file_map are different.

Instead of using the selected_index from the listbox to get the file from the file_map, you should get the filename directly from the listbox.

So change this:


    def show_file_content(self, event):
        self.currently_marked_tag = []
        selected_index = self.listbox.curselection()
        if not selected_index:
            return

        self.current_file = list(self.file_map.keys())[selected_index[0]]
        tag_file_path = os.path.join(self.current_directory, self.current_file)

        self.unique_tags, self.common_words_tags = self.read_tags_from_file(tag_file_path)
        self.removed_tags = []

        self.tags = self.unique_tags.copy()
        for tags in self.common_words_tags.values():
            self.tags.extend(tags)

        self.create_tag_widget()
        self.resize_image()

To this:


    def show_file_content(self, event):
        self.currently_marked_tag = []
        selected_index = self.listbox.curselection()
        if not selected_index:
            return

        self.current_file = self.listbox.get(selected_index) ### This line. ###
        tag_file_path = os.path.join(self.current_directory, self.current_file)

        self.unique_tags, self.common_words_tags = self.read_tags_from_file(tag_file_path)
        self.removed_tags = []

        self.tags = self.unique_tags.copy()
        for tags in self.common_words_tags.values():
            self.tags.extend(tags)

        self.create_tag_widget()
        self.resize_image()

Some screenshots with the fix applied.

1_fix

2_fix

3_fix

Not thoroughly tested, but it appears to work as expected now.

This was a tough/fun issue to sus out! I originally thought it was related to the natural_sort_key function and was running in circles fixing nothing. Eventually I added print statements to everything and found the file_map was correct, but there was a discrepancy with the selected_index and self.current_file.

Double clicking the tag_entry field removes listbox selection.

When double-clicking the tag_entry field, the focus is moved away from the listbox. This clears the selection and prevents all navigation besides manually clicking an entry from the listbox. There may have been other ways of breaking listbox focus, but I never found them. Regardless, this fix should cover all circumstances.

This is a pretty simple fix. We can just set the exportselection flag to false for the listbox. This prevents the listbox from using the primary selection, and allows it to retain its selection when a different widget gets focus.

Line 43 reference.

Simply add exportselection=False to the above statement like this:

self.listbox = tk.Listbox(self.left_frame, selectmode=tk.SINGLE, yscrollcommand=scrollbar.set, exportselection=False)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.