Computer vision model for classifying wildlife species in camera trap images from Gorongosa National Park
# Gorongosa National Park
## How New Images Are Processed
When you run training.py, the script always scans the image folder. If a cached file exists: (`resnet_training/full_df_filtered.csv`), the script will:
- Load the cached filtered dataframe
- Compare filenames against the current folder
- Detect new images not previously processed
- Run MegaDetector only on those new images
- Append passing images to the cached CSV
- Save the updated CSV
- This prevents reprocessing the entire dataset.
First run : If the cached CSV does not exist, MegaDetector runs on all images and a CSV is created
Subsequent Runs : Only new images are processed so it is much faster
π Expected Directory Structure
```text
gorongosa-classifier/
βββ classifier/
β βββ training.py
β βββ inference.py
β βββ splitting.py
β βββ detector.py
β βββ dataloader.py
β βββ utilities.py
β
βββ images/
β βββ all_species_images/
β βββ IMG_0001_{site}_{class}.jpg
β βββ IMG_0002_{site}_{class}.jpg
β βββ ...
β
βββ resnet_training/
βββ full_df_filtered.csv
βββ last_epoch_predictions_*.json
βββ last_model_state_resnet18_*.pkl
```
π§ MegaDetector Threshold
Configured inside training.py:
`"megadetector_conf": 0.2`
## Typical values:
```text
Threshold Behavior
0.1β0.2 Permissive (keeps more animals, more false positives)
0.3β0.4 Balanced
0.5β0.6 Strict (fewer false positives, may miss small animals)
```
Change this value if:
- too many empty images are kept β increase threshold
- animals are being missed β decrease threshold
π Running Training
Activate environment:
`conda activate speciesnet`
Run training:
`python training.py`
If new images were added, only those will be processed by MegaDetector.
π§ͺ Running Inference
Single image :
`python inference.py --image path/to/image.jpg`
Folder :
`python inference.py --folder path/to/images`
Folder + save CSV :
`python inference.py --folder path/to/images --output preds.csv`
The script automatically load β¦