Skip to content
Back to skills

Post Training Tools

ASecurity

"Use after DeepDanbooru training to convert a saved Keras model to

  • 247 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added September 8, 2026
toolsgoapibackend

Works with

  • cli
  • api

Security analysis

A100/100

Pro scans all 6 files and shows the line behind each finding

Scanned September 8, 2026

npx -y skills add VectorSpaceLab/AREX-Skill --skill post-training-tools --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Post Training Tools?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Post Training Tools
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/vectorspacelab-post-training-tools/badge)](https://www.skillsdirectory.com/skills/vectorspacelab-post-training-tools)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: post-training-tools
description: "Use after DeepDanbooru training to convert a saved Keras model to
  TensorFlow Lite or generate experimental Grad-CAM visualizations, with
  explicit artifact, dependency, and CPU-backend checks."
disable-model-invocation: true
metadata:
  disco-role: operating
license: MIT
---

# Post-training tools

Use this sub-skill after a DeepDanbooru project has a loadable trained Keras
model. It routes two post-training workflows:

- **TFLite conversion**: emit and inspect a non-empty `.tflite` artifact.
- **Grad-CAM**: generate experimental, qualitative maps for tags selected by a
  prediction threshold.

Do not use this skill to train, repair a dataset, or judge model quality. Route
ordinary predictions, thresholds, and tag alignment to
[Inference and evaluation](../inference-evaluation/SKILL.md). Route missing or
stale models and retraining to [Model training](../model-training/SKILL.md).
For exact details, read the focused references before running a command.

## Choose the route

| Goal | Entry point | Read first |
|---|---|---|
| Convert a saved Keras model | `deepdanbooru conv2tflite` | [TFLite conversion](references/tflite-conversion.md) |
| Visualize input gradients | `deepdanbooru grad-cam` | [Grad-CAM workflow](references/grad-cam-workflow.md) |
| Check paths without loading a model | `post_training_preflight.py` | [Troubleshooting](references/troubleshooting.md) |
| Verify conversion in isolation | `tflite_conversion_smoke.py` | [TFLite conversion](references/tflite-conversion.md) |

## Shared preflight

1. Use the verified CPU TensorFlow backend first. GPU may be faster, but GPU
   support and speed are optional and unverified; a GPU option is not proof of
   GPU readiness.
2. Keep the model/project and output paths explicit. For TFLite output,
   `--allow-existing-output` only permits replacing an existing regular file;
   an existing directory at `--save-path` is always rejected. Use a disposable
   output directory for Grad-CAM because files can be overwritten.
3. A project-based operation expects `project.json`, `tags.txt`, and the model
   selected by `project.json`. The project loader searches
   `model-{model}.keras`, then `model-{model}.h5`.
4. Check that the model has an NHWC image input and that the tag count matches
   the output width before interpreting results. DeepDanbooru preprocessing
   resizes with aspect-ratio preservation, edge-pads, and normalizes to `[0,1]`.
5. Run the bundled preflight before an expensive conversion or visualization.
   It performs no downloads, network access, credential use, or model loading.

## TFLite decision rules

The CLI requires `--save-path`, a project or direct model path, and at least one
optimization method. The exact flags are `--project-path`, `--model-path`,
`--save-path`, `--optimize-default`, `--optimize-experimental-sparsity`, and
`--verbose`; do not substitute similarly named flags. A direct `--model-path`
takes precedence over a project. The converter API and artifact checks are in
[references/tflite-conversion.md](references/tflite-conversion.md).

After conversion, require `test -s OUTPUT.tflite`; then, when possible, load it
with a CPU TFLite interpreter and call `allocate_tensors()`. A non-empty file
alone does not prove compatible preprocessing, tag metadata, delegates, or
model quality. If sparsity or a layer is incompatible, retry without sparsity
before changing the original model.

## Grad-CAM decision rules

`grad-cam` is explicitly experimental. It requires a project and target path,
accepts an optional output directory (default `.`), and uses `--threshold`
default `0.5`; selection is inclusive (`score >= threshold`). It creates an
input image and per-selected-tag maps under a folder named for each input
basename. No selected tags means no result maps, not necessarily a failed
inference. Read the output contract and limitations in
[references/grad-cam-workflow.md](references/grad-cam-workflow.md).

## Failure handling and handoff

Use [references/troubleshooting.md](references/troubleshooting.md) for missing
model/save/optimization inputs, incompatible conversion operators, absent
SciPy or Pillow imports, malformed projects, and threshold cases with no maps.
Do not import the old `deepdanbooru.gradcam` module as a generic helper: its
source-level experimental test runs at import time. After any artifact or map
run, compare predictions and prerequisites through
[Inference and evaluation](../inference-evaluation/SKILL.md); if the model is
missing, use [Model training](../model-training/SKILL.md).

Files in this skill

  • SKILL.md4.5 KB
  • references/grad-cam-workflow.md4.1 KB
  • references/tflite-conversion.md4.9 KB
  • references/troubleshooting.md4.9 KB
  • scripts/post_training_preflight.py5.2 KB
  • scripts/tflite_conversion_smoke.py4.6 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.