santa hat
deerdeer nosedeer glow
Sign In

Tools/ Scripts I made and use in my workflow

Tools/ Scripts I made and use in my workflow

I wanted to share some tools I've created to streamline my workflow. I thought some might find them helpful too. (I made these using ChatGPT, so I didn't write the scripts myself.) All of these tools are Python scripts, and you can download them all in the attached zip file. Each script comes with a .bat file to help those who aren't as comfortable with this stuff, hopefully lowering the barrier of entry. This article might feel a bit hand-holdy for some, but I want to make sure everyone can use these.

Prerequisites

Make sure you have:

  • Python installed

  • Pip installed

You'll also need to install the following packages:

  • pillow

  • tqdm

  • opencv-python

  • scikit-learn

  • tkinter (usually pre-installed with Python on Windows unless you're using a custom version)

How to Install the Packages

These instructions are for Windows. If you're using macOS or Linux, you'll need to look up the instructions for those systems. Sorry!

  1. Open Command Prompt:

    • Press Win + R to open the Run dialog.

    • Type cmd and press Enter.

  2. Install the Packages:

    • Ensure you have Python and Pip installed.

  3. Type the following commands separately and press Enter to install the packages:

pip install pillow 
pip install tqdm
pip install scikit-learn
pip install tkinter 
pip install opencv-python

How to Use These Tools

It's very simple. First, download the zip file and extract it to a location you can easily find. You'll see four folders, each named according to what the script does. Choose a script you want to use by opening its folder, then click the .bat file. This should run the script. If it doesn't run, you may need to install some additional dependencies.

Background Changer (Updated)

This script modifies the background color of PNG images with transparent backgrounds. Simply select the folder containing your images, and a new folder will be created within it, containing the updated images with changed backgrounds. You can also choose to apply gradients with three different styles and there are newly added color options to address similarity issues. The script allows you to select subdirectories for processing, providing flexible and enhanced background customization.

Batch Zip Folders

This script batch zips folders in a directory. It doesn't have a UI, but it works similarly to the Background Changer. Select the folder you want to batch zip, then select the destination. This process might take some time, depending on your computer specs and the amount of data being zipped. I created this to save space on my computer since zipping folders can reclaim some storage. Training hundreds of models with saved data can take up a lot of space, and this helps me get some of it back. Plus, I'm a bit lazy.

Image Rounder

This script lets you specify input and output folders. You can then enter the number of images you want to keep. Hit the execute button, and the images will be randomly sorted into "keep" and "delete" folders. I don't use this one often, but it's handy when I'm creating a style or concept and have over 500 images. It helps me choose the images since I'm bad at making decisions. Did I mention I'm lazy?

Move to One Folder From Sub Folders

This script is quite situational and might not be useful to everyone, but it's here if you need it. I use it when I download a game's CG or a collection of an artist's work. Often, these come with a convoluted folder structure, sometimes with folders inside folders. Instead of moving each image manually into a big folder, which can be time-consuming, you can use this script. Just select the input and output folders. Each image will be randomly renamed to avoid overwriting.

Extract Video Frames (New)

This script lets you extract video frames from any video you would like. I made this so you can batch process lots of videos at once. You can select how many frames per second you want to extract. After choosing the number (default is 1), you can choose the folder with the videos. New folders with the video titles will appear, containing the extracted frames.

-Update: Should now work for webm video formats

Sort images by style (New)

This tool may not fully meet all your style-sorting needs, but it is effective for filtering out images that should not be in your dataset. Once you run the script, please allow a few seconds for processing, depending on your hardware capabilities.

You will be able to click a button to select multiple images (ctrl + click any images to select) . These images serve as a reference for identifying and sorting the style you're interested in. After selecting your reference images, you'll choose the folder containing the images to be sorted. The tool will then organize the images and create a new folder with them. Inside this folder, images will be grouped into subfolders labeled by percentages.

Conclusion and Questions

I will continue to update this article if I create more of these. Feel free to comment on this article if you have any issues. You can also message me directly via Civitai chat or my Discord: guy90.

16

Comments