Sign In

[Python] LoRA File Management Tool

[Python] LoRA File Management Tool

User Guide for LoRA File Management Tool

Introduction

This tool assists in organizing LoRA files across your network or USB storage. It's designed for users with either network or external storage solutions, or those who store AI models on local drives and larger data on external drives. The script facilitates efficient and stylish data transfer between these storage options.

This tool is completely open-source, license-free, and gluten-free! It can be viewed, reverse-engineered, or customized.

I would still appreciate a like or a thank you ;)

Appendix

  • LoRADB: Your network location for storing large amounts of LoRA files.

  • LoRA Location: The model directory for tools like A1111 or Fooocus.

This script is compatible with all AI tools unless they use their own model manager with encrypted storage.

Configuration

To configure the script, open loramanager.py in your preferred editor (Visual Studio recommended).

Edit lines 10 and 11:

source_drive = r"PATH_TO_LORADB" 
destination_drive = r"PATH_TO_LORA_LOCATION"

LoRADB Specification

  • Example LoRA: test.safetensors

  • Directory Structure:

    • \safetensors\test.safetensors

    • \images\test\Images.png

    • \categories.txt

Place all LoRA files in the safetensors folder and example images in the images folder, creating subfolders for each LoRA.

categories.txt Format:

Modelname:Category

Each line should contain one model entry, e.g.:

test1:testcategory 
test2:testcategory 
test3:testcategory2 
test4:testcategory2

Using the ModelManager

Once configured, launch the script via Python:

  1. Command Line:

    • Navigate to the script location and run python loramanager.py.

  2. GUI:

    • Right-click the script and select "Open with Python".

Interface Overview

  • Left Panel: Category view (controlled by categories.txt).

  • Middle Panel: Models within the selected category.

  • Right Panel: Preview image of the selected model.

  • Bottom Panel: Connect/Close File buttons.

Steps to Use

  1. Select a category.

  2. Choose the desired model.

  3. Click "Connect" and wait for confirmation.

  4. Refresh in A1111/Fooocus and use the model.

  5. Once finished, click "Close file".

Functions:

  • Connect: Copies the LoRA to your model directory.

  • Close File: Removes the LoRA from your model directory (LoRADB remains unchanged for security).

Known Bugs

  1. The model list clears when a model is selected, but the model remains selected and can be connected. (Fixed in V2 - See below)

  2. Selecting a different model while one is connected will disconnect it, requiring manual deletion. This issue does not occur if only one model is selected at a time. (Fixed in V2 - See below)

UPDATE V2

The LoRA Manager has received a small update. (LoraManagerV2)

Small adjustment in the config: SOURCE_DRIVE and DEST_DRIVE need to be set. They are now in lines 8 and 9. Some of the libraries have been reduced.

First, visually (see preview image below), and second, functionally. Previous bugs have been fixed, and in addition to Model Connect, Category Connect has now been added.

You can now copy multiple models or entire categories, no longer limited to one at a time.

Using the buttons at the bottom left:

  • Connect: Copies the currently selected model to the LoRA directory.

  • Close File: Deletes the currently selected model from the LoRA directory.

  • Connect Category: Similar to 'Connect,' but copies the entire category.

  • Close Category: Removes only the selected category.

  • Clear: Removes all models from the LoRA directory, typical housekeeping.

Additionally, the tool automatically removes all models from the LoRA directory when the window is closed, keeping the directory clean and saving space.

Nerd section: Currently used Python libraries:

  • os

  • shutil

  • random

  • tkinter

  • tkinter/messagebox

  • PIL/Image

  • PIL/ImageTk

Preview:

8

Comments