Lora Sorter (python checkpoint type inspection tool)

Details

Download Files

Model description

This is a pair of Python scripts that detect Lora base model types and move the Loras into appropriate folders.

If you have 1000+ Loras in the same folder and you're not sure which one is SD, which is SDXL, which is Flux etc., this Python program analyzes all of them, generates a plan, and gives you a chance to check and correct its work before you execute the plan.

There are three basic steps.

  1. scan the folder, analyze the files, generate the first CSV (spreadsheet) file

  2. read the CSV file, determine what goes where, show the plan to the user

  3. execute the plan

NOTE: Between steps 2 and 3, you should open and review/correct the CSV file contents.

The basic commands:

  1. python inspect_lora.py "X:\path_where_the_lora_safetensor_files_are\"

  2. python inspect_sort_lora.py lora_inspect_index.csv

  3. python inspect_sort_lora.py lora_inspect_index.csv --base "..." --apply

I encourage you not to run "apply" until you have had a really good look at the second CSV file's contents (lora_inspect_index_sort_plan.csv), because this thing does make some mistakes, it often confuses older SD and SDXL loras or the ones that weren't generated cleanly.

The point of the three step process is to give you a chance to correct its mistakes.

PART 1/2 - inspect_lora.py

  • This will analyze all of the targeted Lora files and generate a CSV file.

CSV columns that will be generated: (some will be unpopulated until the next step)

  • {path family, total_tensors, has_flux_blocks, has_input_blocks, has_down_blocks, has_dual_te, error, maybe_flux, maybe_sdxl, maybe_sd, maybe_lcm_turbo, maybe_ltxv, maybe_pony, maybe_ponyxl, maybe_qwen, maybe_wan, move destination}

CLI Usage: (command line options):

  • python inspect_lora.py "D:\AI\stable-diffusion-webui\models\Lora\some_lora.safetensors"

  • python inspect_lora.py "D:\AI\stable-diffusion-webui\models\Lora\*.safetensors"

  • python inspect_lora.py "D:\AI\stable-diffusion-webui\models\Lora\SD\"

PART 2/2 - inspect_sort_lora.py

This script reads lora_inspect_index.csv and proposes (or applies) a sort of LoRAs by family. It is designed to work with the output from inspect_lora.py.

This script...

  • loads that CSV

  • for each row with a valid path and no error, decides which "bucket" the LoRA belongs to (e.g. "SDXL", "SD15", "Flux", "Unknown")

  • optionally moves the files into subfolders based on that bucket

  • always writes a second CSV with the plan / results: lora_sort_plan.csv

CLI Usage: (command line options):

  • python inspect_sort_lora.py lora_inspect_index.csv

  • python inspect_sort_lora.py lora_inspect_index.csv --base "D:\AI\stable-diffusion-webui\models\Lora"

  • python inspect_sort_lora.py lora_inspect_index.csv --base "..." --apply

Images made by this model

No Images Found.