Views
No views yet
git clone https://huggingface.co/RedRocket/JTP-3..py files, requirements.txt, models/jtp-3-hydra.safetensors, and data/jtp-3-hydra-tags.csv..bat files and follow the instructions below for easy installation.data/jtp-3-hydra-val.csv.easy.bat and it will let you know.easy.bat to run easy mode.
Easy mode walks you through all the commands.
When easy mode asks you for a file or folder, you can drag and drop it onto the easy mode window and press enter, copy and paste the path, or type it yourself.install.bat to run installation, which will create a virtual environment for all the requirements and install them.
You can check your version of Python by opening a command prompt and typing python -V.app.bat and navigating your browser to the URL it shows. The link is not shared publicly.inference.bat to do bulk operations such as tagging entire directories. Run inference.bat --help for help using the command line.
If you provide a path to a file or directory, it will write .txt caption files beside each image using the default threshold of 0.5.calibrate.bat.python to create the venv.
You can check your version of python with python -V.1python -m venv venv
2source venv/bin/activate
3pip install -r requirements.txt1source venv/bin/activate
2python app.py1source venv/bin/activate
2python inference.py --help0.5 is conservative. If you plan on manually reviewing the tags, consider using -t 0.2 or -t 0.1.$ python inference.py --help
usage: inference.py [-h] [-t THRESHOLD_OR_PATH] [-i MODE] [-x CATEGORY] [-p PREFIX] [-o PATH] [-O] [-M PATH] [-m PATH] [-e PATH] [-E] [-b BATCH_SIZE] [-w N_WORKERS] [--no-shm] [-S SEQLEN] [-d TORCH_DEVICE] [-r] [PATH ...]
positional arguments:
PATH Paths to files and directories to classify. If none are specified, run interactively.
options:
-h, --help show this help message and exit
-r, --recursive Classify directories recursively. Dotfiles will be ignored.
classification:
-t, --threshold THRESHOLD_OR_PATH
Classification threshold -1.0 to 1.0. Or, a path to a CSV calibration file. (Default: calibration.csv)
-i, --implications MODE
Automatically apply implications. Requires tag metadata. (Default: inherit)
-x, --exclude CATEGORY
Exclude the specified category of tags. May be specified multiple times. Requires tag metadata.
output:
-p, --prefix PREFIX Prefix all .txt caption files with the specified text. If the prefix matches a tag, the tag will not be repeated.
-o, --output PATH Path for CSV output, or '-' for standard output. If not specified, individual .txt caption files are written.
-O, --original-tags Do not rewrite tags for compatibility with diffusion models.
model:
-M, --model PATH Path to model file.
-m, --metadata PATH Path to CSV file with additional tag metadata. (Default: data/jtp-3-hydra-tags.csv)
-e, --extension PATH Path to extension. May be specified multiple times. If a directory is specified, all extensions in the specified directory are loaded. (Default: extensions/jtp-3-hydra)
-E, --no-default-extensions
Do not load extensions by default.
execution:
-b, --batch BATCH_SIZE
Batch size.
-w, --workers N_WORKERS
Number of dataloader workers. (Default: number of cores)
--no-shm Disable shared memory between workers.
-S, --seqlen SEQLEN NaFlex sequence length. (Default: 1024)
-d, --device TORCH_DEVICE
Torch device. (Default: cuda)
MODE:
inherit Tags inherit the highest probability of the more specific tags that imply them.
constrain Tags are constrained to the lowest probability of the more general tags they imply.
remove Exclude implied tags from output.
constrain-remove Combination of constrain followed by remove.
off No implications are applied.
CATEGORY:
general artist copyright character species meta loreinference.py at once, as each copy will load the entire model.
If you are tagging only a few images, run with -w 0 to use in-process dataloading.inference.py will launch in an interactive mode where you can provide files one-at-a-time.$ python inference.py
JTP-3 Hydra Interactive Classifier
Type 'q' to quit, or 'h' for help.
For bulk operations, quit and run again with a path, or '-h' for help.
> h
Provide a file path to classify, or one of the following commands:
threshold NUM (-1.0 to 1.0, 0.2 to 0.8 recommended)
calibration [PATH] (load calibration csv file)
exclude CATEGORY (general copyright character species meta lore)
include CATEGORY (general copyright character species meta lore)
implications MODE (inherit constrain remove constrain-remove off)
seqlen LEN (64 to 2048, 1024 recommended)
quit (or 'q', 'exit')safe, questionable, and explicit.-i off.
For example, with implications off it's possible the model can say tyrannosaurus rex is more likely than dinosaur.
In the default inherit mode, it will instead say that dinosaur is as likely as tyrannosaurus rex.
In the constrain mode, it will say that tyrannosaurus rex is as likely as dinosaur.ENTER to get the default calibration until it asks you for a list of tags to exclude.
If you don't want to exclude any tags, press ENTER again and answer y to get the default calibration..py and tells you to run it. However, .csv calibration files are always safe..safetensors files similar in spirit to LORAs.
By default, .safetensors files placed in extensions/jtp-3-hydra will be loaded as extensions..bat wrapper files which load the virtual environment are intentionally not provided.pip install triton-windows with the virtual environment active.
CPU training is not supported due to the dependency on Triton.
If you really want to train on a platform not supported by Triton, manually replace the optimizer, perhaps with AdamW in float32.train directory (or elsewhere):tag_name/
positive/
negative/positive directory.
For best results, you must manually review every image to ensure it has the tag you are trying to train.
Try to use a diverse set of images having the tag. Don't just use your favorite images, especially if they are from a single artist.negative directory.
For best results, you must manually review every image to ensure it does not have the tag you are trying to train.dragon_on_top_gryphon_on_bottom with 200 positive examples. Your negative set might look like:python train_extension.py --help to familiarize yourself with the options provided by the training script.-b/-B) and/or gradient accumulation (-a) to match your available VRAM.-v 20.
(Note that the -v option reserves an equal number of positive and negative examples. The default -v 20 reserves 40 total examples, 20 positive and 20 negative.)-c/-e).$ python train_extension.py -c 0 example_tagLoading 'models/jtp-3-hydra.safetensors' ... 7504 tags
caching: 100%|█████████| 200/200 [00:19<00:00, 11.02it/s]
...
EPOCH 1 VALIDATION: loss=0.6758, cti=0.5556, thr=0.4501
EPOCH 2 VALIDATION: loss=0.6633, cti=0.5556, thr=0.4501
EPOCH 3 VALIDATION: loss=0.6320, cti=0.5882, thr=0.4800
EPOCH 4 VALIDATION: loss=0.5922, cti=0.6923, thr=0.5499
...
EPOCH 65 VALIDATION: loss=0.0106, cti=1.0000, thr=0.0804
EPOCH 66 VALIDATION: loss=0.0105, cti=1.0000, thr=0.0804
EPOCH 67 VALIDATION: loss=0.0112, cti=1.0000, thr=0.0901
EPOCH 68 VALIDATION: loss=0.0115, cti=1.0000, thr=0.0995
EPOCH 69 VALIDATION: loss=0.0116, cti=1.0000, thr=0.1097
EPOCH 70 VALIDATION: loss=0.0113, cti=1.0000, thr=0.0995
...train/example_tag/checkpoints/<timestamp>_e66.pt.python build_extension.py --help to familiarize yourself with the options provided by the extension builder.
The extension builder converts pytorch checkpoints in training mode to inference-ready safetensors files with additional metadata, of which some is essential.$ python build_extension.py -a "Project RedRocket" train/example_tag/checkpoints/<timestamp>_e66.pt example_tag generalLoading checkpoint 'train/example_tag/checkpoints/<timestamp>_e66.pt'...
Preparing metadata...
modelspec.sai_model_spec: '1.0.0'
modelspec.architecture: 'naflexvit_so400m_patch16_siglip+rr_hydra'
modelspec.implementation: 'redrocket.extension.label.v1'
modelspec.description: 'This is an extension for the RedRocket JTP-3 Hydra image classifier. You can find usage instructions at https://huggingface.co/RedRocket/JTP-3.'
modelspec.date: '<timestamp>'
modelspec.tags: 'Image Classification'
classifier.label: 'example_tag'
classifier.label.category: 'general'
modelspec.title: 'JTP-3 Hydra Extension: example_tag'
modelspec.author: 'Project RedRocket'
modelspec.license: 'MIT'
modelspec.language: 'en/US'
Building extension...
Apply optimizer state: attn_pool.q
Apply optimizer state: attn_pool.out_proj.weight
Normalize: attn_pool.q
Saving extension 'extensions/jtp-3-hydra/example_tag.safetensors'....safetensors files is included as edit_metadata.py. You can use this to view and edit already-built extensions, perhaps to change the tag name or add implications.male_feral.data folder.
These can be used to create P/R curves, compute CTI or F1 scores, or select automated thresholds for each tag.
The list of supported tags is also embedded in the safetensors metadata as classifier.labels.data files and csv output of inference.py.