CivArchive
    Preview 62844999Preview 62848125Preview 62902682Preview 62930490

    LoRAS CAN BE A PAIN!

    safetriggers.py is a CLI Python Script for Linux (tested on Ubuntu Server 24.10) capable of extracting the TAGS, TRIGGER-WORDS and TRIGGER-PHRASES from LoRAs trained on tagged source images and presenting them on screen OR saved as a;

    <LoRA name>.safetriggers

    file alongside your LoRA for distribution to users for quick reference, as a small and simple JSON text file.

    NOTE. LoRAs (*.safetensors) are UNAFFECTED and only ever read.

    Triggers are SORTED with most important FIRST in the list, in order of the occurance of tags in the source images, as trained.

    This makes it easy to see what a LoRA is really trained on and can be surprising.

    Q. LoRA USER! WANT AN EASY WAY TO SEE WHAT THE TRIGGERS ARE FOR A LoRA NAMED "foo_bar.safetensors"?

    python3 safetriggers.py --lora foo_bar

    Q. LoRA CREATORS! WANT AN EASY WAY TO MAKE A FILE TO ACCOMPANY YOUR LoRA TELLING USERS WHAT TRIGGERS MAKE YOUR LoRA NAMED "foo_bar.safetensors" WORK?

    python3 safetriggers.py --mksafetriggers --lora foo_bar

    Q. LoRA CREATORS! WANT AN EASY WAY TO SEE WHAT TAGS YOUR LoRA IN "./loras/foo_bar.safetensors" HAS BEEN TRAINED FOR AND WHAT IT HAS FOUND SIGNIFICANT FROM YOUR SOURCE IMAGES?

    python3 safetriggers.py --mksafetriggers --lorapath ./loras --lora foo_bar

    ...and it will create a "./loras/foo_bar.safetriggers" file containg that info to process, read, examine or distribute with the .safetensors file.

    VERSION 2025Mar11 onward;

    With the new -allloras option there's no need to name individual LoRAs using -lora so if you need to examine and generate .safetriggers files for all LoRAs in a -lorapath and subpaths then;

    python3 safetriggers.py --mksafetriggers --allloras --lorapath ./loras/nsfw

    VERSION 2025Mar13 onward;

    With the new -safetriggers option you can name an individual LoRAs .safetriggers file and display its contents on-screen, for example;

    python3 safetriggers.py --lorapath ./loras/nsfw --safetriggers PrettyWomen-f1-v8

    to display on-screen the SORTED tags and trigger-words and trigger-phrases it has been trained on.

    VERSION 2025Mar16 onward;

    With the new option you can name an individual LoRAs .safetriggers file and display its contents on-screen, for example;

    python3 safetriggers.py -p ./loras/nsfw -s PrettyWomen-f1-v8

    to display on-screen the SORTED tags and trigger-words and trigger-phrases it has been trained on.

    These shorter CLI parameters are listed on-screen by typing;

    python3 safetriggers.py -h

    NOTE.

    SOME LoRAs CONTAIN NO TAGS ( and safetriggers can identifty these) SO THERE'S NOTHING TO READ, SO YOUR ONLY OPTION IS TO CONTACT THE CREATOR OF THE LoRA TO DISCOVER HOW THEY INTENDED YOU TO USE IT!

    safetriggers.py

    Use this handy tool for quickly examining the TAGS and TRIGGER-WORDS and TRIGGER-PHRASES in the META_DATA in LoRAs.

    To read a "<LoRA name>.safetriggers" text file in your code using this snippet;

    import os
    import json
    
    with open('lora.safetriggers') as f: 
        data = f.read()
    
    lora_triggers_dictionary = json.loads(data)
    
    print(lora_triggers_dictionary)

    DISCLAIMER;

    CURRENT VERSION IS ABLE TO READ AND ANALYZE SOME COMMON LoRA FORMATS BUT NOT ALL.

    Check later versions.

    NOTE...

    INITIAL VERSION, A PROOF OF CONCEPT, WAS WRITTEN WHEN I WAS GETTING OVER A MIGRAINE AND SOME CODE DECISIONS MAY HAVE BEEN MADE USING A MAGIC-8-BALL, FOR WHICH I NOW HAVE REGRETS! USE LATER BETTER VERSIONS.

    Description

    FASTER

    BETTER

    DEEPER

    Added -allloras for processing ALL LoRAs in a folder, and subfolders

    Bug Fixes, Exceptions Caught & Typos

    Other
    Other

    Details

    Downloads
    42
    Platform
    CivitAI
    Platform Status
    Available
    Created
    3/11/2025
    Updated
    9/27/2025
    Deleted
    -

    Files

    safetriggersPythonToolFor_safetriggersPy.zip