This repository contains scripts for training and performing inference using an animal classification model. The model is trained on an animal dataset and can classify images and videos.
📂 Animal-Classifier
│── 📂 checkpoints/ # Directory for saving model checkpoints
│── 📂 logs/ # TensorBoard logs
│── 📂 outputs/ # Directory for saving processed videos
│── 📂 dataset/ # Dataset directory (if applicable)
│── 📄 animals_train.py # Script for training the model
│── 📄 animals_inference_image.py # Script for image classification inference
│── 📄 animals_inference_video.py # Script for video classification inference
│── 📄 animals_dataset.py # Dataset class
│── 📄 animals_model.py # Model definition
│── 📄 requirements.txt # Python dependencies
│── 📄 README.md # Project documentation
- Python 3.8+
- PyTorch
- OpenCV
- NumPy
- Matplotlib
- scikit-learn
- tqdm
- TensorBoard
Run the following command to install required libraries:
pip install -r requirements.txt
To train the model, use:
python animal_train.py --data-path ./dataset --epochs 50 --batch-size 64 --learning-rate 0.001
Arguments:
--data-path
: Path to the dataset--epochs
: Number of training epochs--batch-size
: Batch size for training--learning-rate
: Learning rate--resume
: Resume training from the last checkpoint (optional)
tensorboard --logdir ./logs
To classify a single image:
python animals_inference_image.py --image-path ./test_image.jpg --checkpoint-dir ./checkpoints
Arguments:
--image-path
: Path to the input image--checkpoint-dir
: Directory containing model checkpoints--checkpoint-name
: Name of the checkpoint file (default: best_model.pt)
To classify animals in a video:
python animals_inference_video.py --video-path ./test_video.mp4 --checkpoint-dir ./checkpoints --show-video
Arguments:
--video-path
: Path to the input video--frame-size
: Size to resize frames (default: 224)--checkpoint-dir
: Directory containing model checkpoints--checkpoint-name
: Name of the checkpoint file (default: best_model.pt)--show-video
: Display the video with predictions in real-time
- Training logs are stored in
logs/
(can be viewed using TensorBoard). - Checkpoints are saved in
checkpoints/
. - Processed videos are saved in
outputs/
.