Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug - Opening a folder deletes the first caption file #25

Closed
MNeMoNiCuZ opened this issue Jul 25, 2024 · 6 comments
Closed

Bug - Opening a folder deletes the first caption file #25

MNeMoNiCuZ opened this issue Jul 25, 2024 · 6 comments

Comments

@MNeMoNiCuZ
Copy link

Pretty consistently, when I open a folder with existing captions, it deletes the caption from the first file.

It smells like an issue with "Autosave" being true, but I haven't really investigated too much.

Let me know if you are unable to reproduce.

@Nenotriple
Copy link
Owner

I cannot trigger this issue, please list out the steps needed to reproduce it.

@MNeMoNiCuZ
Copy link
Author

MNeMoNiCuZ commented Aug 31, 2024

Here I have a folder of captioned files:
image

I then open that folder inside img-txt_viewer, with the "Auto-save" option turned on.
image

This literally deletes the caption of the first image if you have "Auto-save" checked when you open an existing dataset.

If you do the same without "Auto-save" it does not delete the file.
It's likely calling "Save" with an empty text field, before it loads the existing captions, thus overwriting the original caption with nothing, and therefore deleting it.

Sidenote:
I don't know if it's desired to delete the caption when the text is empty. Maybe this could be an option? You may want to have an empty caption file. This is useful in Flux trainings, that can learn well from empty captions, or mixed type captions.

@Nenotriple
Copy link
Owner

This appears to be the same as issue #23, ae56143. In your screenshots, the app is v1.93, the issue is no longer present in the current version. I'm definitely sorry you encountered this bug, it was exactly what you expected was happening.

I always figured images without a text pair would be treated the same as if they had an empty text pair (e.g., a text file of the same name, without text captions). Regardless, I can add an option to prevent text files from being deleted when they're saved blank. I'll also do something to handle the other unpaired images in the working folder.

@MNeMoNiCuZ
Copy link
Author

Confirmed, it works well in 1.94.
Sorry for not checking latest.

Regarding empty text pairs / deleting files:
I'm not sure which is a better default behavior is more desirable. But it seems worse to delete people's files if they existed, without the user having a say in it. An option does make sense.

I think my UX suggestion is to have deleting be off by default. It's faster to delete a bunch of files than it is to create new empty ones.

This could also be a useful feature, to have it create those empty files as you open a folder. But it may also be getting too niche.

@Nenotriple
Copy link
Owner

worse to delete people's files if they existed, without the user having a say in it
This makes complete sense, I'll make the option "Auto-Delete Blank Files" off by default when it's implemented.

I'll consider having the app automatically create text files when you load a directory, but I think it would be best to have this as a tool menu command. I guess it could also be a toggleable option.

@MNeMoNiCuZ
Copy link
Author

Depending on how much bloat your options get, it may be better as a one-off script.
Personally, a setting sounds better to me if you can afford the space for it :)

Nenotriple added a commit that referenced this issue Sep 5, 2024
  - New:
    - New tab `Stats`: View file stats related to the current directory, including total files, characters, captions, average characters, words, captions per file, lists of captions, resolutions, common words, and more.
    - New option `Loading Order`: Set the loading order based on name, file size, date, ascending/descending, etc.
    - New option `Reset Settings`: Reset all user settings to their default parameters, with an option to reset “My Tags”.
    - New option `Auto-Delete Blank Files`: Enable this setting to automatically remove blank text files when they're saved. #25
    - New tool `Rename Pair`: Manually rename a single img-txt pair.
    - New tool `Create Blank Text Pairs`: This tool will create a text file for any unpaired image.
    - New tool `Archive Dataset`: Use this to quickly zip the current working folder.
    - New Tool `Batch Upscale`: Same as 'Upscale Image', but this can upscale an entire folder of images.
    - Enhanced text selection for the primary text box and most text entries, treating common punctuation and symbols as word boundaries on double-click and allowing selection of entire entry text strings with a triple-click. #26
    - New text box right-click menu option: `Open Text File...`

  - Fixed:
    - Filtering using regex patterns now works as intended. #27
    - Fixed right-click not triggering the primary textbox context menu if the textbox wasn't initially focused with a left-click.
    - Fixed AttributeError when refreshing the custom dictionary.
    - Fixed the issue where using the `CTRL+S` hotkey to save the text wouldn't display *Saved* in the message label.
    - Fixed `Rename and Convert` improperly naming text file pairs.
    - Improved image loading to prevent [WinError 32], also fixing issues with the “Delete Pair” tool.
    - Improved UI handling of situations where filtering would result in zero matches.
    - Prevented the Image-Grid from opening when there aren't any images to display.
    - The file filter is now cleared when changing the selected directory.

  - Other changes:
    - Toggle Zoom - The popup is now centered next to the mouse and behaves better around the screen edges.
    - `Delete img-txt Pair` now allows you to send the pair to the recycle bin.
    - Navigating pairs while auto-save is enabled is now much faster.
    - You can now set a filter by using the enter/return key with the filter widget in focus.
    - You can now quickly open the "settings.cfg", and "my_tags.csv" files in your default system app.
    - You can now use Regex patterns in the `Search` field of the Search and Replace tool, along with the Highlight tool.
    - You can now use the Up/Down arrow keys to navigate while the img-txt index entry is focus.
    - You can now hold Shift when navigating (all methods) to advance by 5 instead of 1.
    - This message label now displays "No Changes" when attempting to save a file without making changes to it.
    - Ensured auto_save_var is properly restored to its original value if the text box does not exist when changing the working directory.
    - The "Clear" button in the Filter tab now turns red when the filter is active, and the tooltip also changes to show the filter state.
    - The tools *'Rename img-txt Pairs'* and *'Rename and Convert img-txt Pairs'* have been combined into a single tool called `Batch Rename and/or Convert`.
    - Using Undo after S&R/Prefix/Append, will now delete text files that previously didn't exist at the time when those tools were ran.
    - This version comes with many small UI tweaks and updates, along with some minor internal code refactoring.

  - Project Changes:
    - **Image-Grid:** v1.03
      - New:
        - Filtering options are now moved to a new menu.
        - You can now filter images by `Resolution`, `Aspect Ratio`, `Filesize`, `Filename`, `Filetype`, and `Tags`.
          - Along with these operators, `=`, `<`, `>`, `*`
        - Resolution and Filesize are now displayed in the image tooltip.
        - `Auto-Close`: This setting is now saved to the `settings.cfg` file. #24
      - Fixed:
        - Fixed the issue of not being able to focus on the image grid window when selecting it from the taskbar. #24
      - Other changes:
        - Increased the default number of images loaded from 150 to 250.
        - Improved image and text cache.
        - Update index logic to support new loading order options.
    - **Upscale Image:** v1.04
      - New:
        - Now supports batch upscaling a folder of  images.
        - The `Upscale Factor` widget is now a slider allowing you to select `from 0.25`, `to 8.0`, in `0.25 increments`.
        - New settings: `Strength` Set this from 0%, to 100% to define how much of the original image is visible after upscaling.
      - Fixed:
        - Settings are now disabled while upscaling to prevent them from being adjusted while upscaling.
        - Fixed issues with opening and holding-up images in the process.
    - **TkToolTip:** v1.04
      - New:
        - Now supports an ipadx, or ipady value for interior spacing. The default value is 2.
      - Other changes:
        - x_offset, and y_offset have been renamed to padx, and pady.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants