The fastest path to a working prediction is to use the pre-trained model that ships with the repository. Because the weights file (Documentation 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.
kermit_finder.h5) is stored via Git LFS, no retraining is necessary — clone the repo, install the dependencies, and you are one command away from classifying any image or video as kermit or no-kermit. This guide walks through exactly that path.
Prerequisites
Make sure you have the following before you begin:Ubuntu / DebianAfter installation, initialise Git LFS for your user account (only needed once):Then clone the repository so that LFS objects are downloaded automatically:
- Python 3.x — the evaluation script uses
asyncioand type annotations that require Python 3.5+. - pip — used to install all Python dependencies.
- Git LFS — required to download the pre-trained
.h5model that is tracked as a large file in the repository.
Install dependencies
Install all required Python packages from the pinned The file installs the following exact versions to ensure reproducibility:
ImageAI 2.0.2 is installed directly from GitHub because it is not published to PyPI:
requirements.txt:| Package | Version / Source |
|---|---|
tensorflow | 1.12.0 |
tensorflow-gpu | 1.12.0 |
keras | 2.2.4 |
opencv-python | 4.0.0.21 |
imageai | 2.0.2 (GitHub wheel URL) |
pillow | 5.4.1 |
scipy | 1.2.0 |
matplotlib | 3.0.2 |
h5py | 2.9.0 |
pandas | 0.23.4 |
google_images_download | latest |
Verify the pre-trained model exists
After cloning with Git LFS enabled, confirm the two files the inference script depends on are present:If
data/images/models/kermit_finder.h5— the serialised ResNet weights produced byimageai_build_model.py. This file is tracked by Git LFS and should be several hundred megabytes.data/images/json/model_class.json— the class index map used at inference time. Its contents are:
kermit_finder.h5 is only a few hundred bytes, Git LFS did not download the real file. Run git lfs pull to fetch it:Run a prediction on an image
Use Expected output:The script prints the probability for each class. A Each image is predicted independently and its result is printed in turn.
kermit_model_evaluation.py with -t image to classify a single image. Pass the file path with -f:kermit score near 100 confirms the model has high confidence that Kermit the Frog appears in the image.You can also classify multiple images in a single run by passing a comma-separated list of file paths:Run a prediction on a video
To classify every second of a video file, use The script performs the following steps automatically:
-t video:- Frame extraction — OpenCV seeks to each 1-second mark (
CAP_PROP_POS_MSEC) and captures one frame per second for the full duration of the video. - Async batch inference — each extracted frame is submitted as an
asynciocoroutine so all frames are predicted concurrently rather than sequentially. - Annotation — once all predictions are collected, the confidence scores for both classes are rendered as a red text banner at the top of each frame image using
cv2.putText. - Output — annotated frames are saved as JPEGs in the
episode3_results/directory, named sequentially (ep3_frame0.jpg,ep3_frame1.jpg, …).
Next Steps
Prediction Guide
Deep-dive into image and video prediction: batch processing, understanding confidence scores, and interpreting edge cases like Kermit-lookalike characters.
Training Guide
Learn how to build your own labelled dataset, configure training epochs and batch size, and fine-tune the ResNet model from scratch with ImageAI.