Training uses ImageAI’sDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/ilirosmanaj/detect_kermit/llms.txt
Use this file to discover all available pages before exploring further.
ModelTraining class with a ResNet backbone to learn a binary classifier that separates kermit from no-kermit frames. The script reads your prepared image directories, runs for a configurable number of epochs with optional built-in data augmentation, and saves the resulting model weights to an HDF5 file ready for inference. Training time scales with dataset size, epoch count, batch size, and the compute hardware available.
Training script
The full training script is concise by design — ImageAI abstracts away the ResNet architecture, data loading, and checkpoint saving:imageai_build_model.py
Training parameters
| Parameter | Value | Description |
|---|---|---|
num_objects | 2 | Binary classification — the two classes are kermit and no-kermit. |
num_experiments | 20 | Number of full training epochs over the dataset. |
enhance_data | True | Enables ImageAI’s built-in data augmentation (additional flips, shifts, and zoom transforms applied on the fly). |
batch_size | 16 | Number of samples used per gradient update. Lower this value if you run into GPU memory errors. |
show_network_summary | True | Prints the full ResNet layer-by-layer architecture to stdout before training begins. |
Running training
Prepare the dataset
Make sure your
data/images/ directory is fully populated with train/ and test/ subdirectories for both classes before starting. Follow the Dataset Preparation guide if you have not done this yet.Wait for training to complete
Training time varies depending on the number of training images, the value of
num_experiments, batch_size, and your hardware. With 20 epochs on a mid-sized dataset, expect anywhere from several minutes on a GPU to multiple hours on CPU only.Output files
After a successful training run, two key files are produced:data/images/models/kermit_finder.h5 — The trained ResNet weights saved in HDF5 format. This is the file loaded by kermit_model_evaluation.py at inference time.
data/images/json/model_class.json — A JSON file that maps integer class indices to human-readable class names: