You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+26Lines changed: 26 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,6 +4,32 @@ All notable changes to this project will be documented in this file.
4
4
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
5
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
7
+
## [2.0.0] - 2025-01-06
8
+
9
+
### Added
10
+
-**Motion-informed inference**: New detection pipeline using Gaussian Mixture Model (GMM) background subtraction instead of YOLO, with path topology analysis for confirming insect-like movement
11
+
-**Validation module** (`validation.py`): New `bplusplus.validate()` function to evaluate model performance with precision, recall, and F1-score at all taxonomic levels
12
+
-**Configurable ResNet backbone**: Choose between `resnet18`, `resnet50`, or `resnet101` for training and inference
13
+
-**Custom training transforms**: New `train_transforms` parameter for custom data augmentation in `train()`
14
+
-**Validation split control**: New `valid_fraction` parameter (0-1) in `prepare()` to control train/validation split ratio
15
+
-**Detection confidence parameter**: New `conf` parameter in `prepare()` for YOLO confidence threshold
16
+
-**Class imbalance warnings**: Training now analyzes and warns about class imbalance across taxonomic levels
17
+
-**Detection configuration**: Support for YAML/JSON config files to customize motion detection parameters
18
+
-**New prepare weights**: Higher accuracy `gbif-generic` weights for data preparation
19
+
20
+
### Improved
21
+
-**Collect robustness**: Added retry logic with exponential backoff for GBIF API calls, progress tracking, and graceful handling of interruptions
22
+
-**GBIF quality filters**: Enhanced filtering options including `occurrenceStatus`, `year` range, and more
23
+
24
+
### Changed
25
+
-**Inference pipeline**: Replaced YOLO-based detection with motion-based detection using GMM
26
+
-**Output structure**: Inference now outputs to a single directory with multiple files (`_annotated.mp4`, `_debug.mp4`, `_results.csv`, `_detections.csv`)
27
+
-**Results CSV**: Now contains only aggregated results for confirmed tracks
28
+
29
+
### Removed
30
+
-**YOLO dependency for inference**: No longer requires YOLO weights for video inference
**Note:** The `num_workers` parameter controls DataLoader multiprocessing (defaults to 0 for stability). You can increase it for potentially faster data loading.
113
+
**Note:** The `num_workers` parameter controls DataLoader multiprocessing (defaults to 0 for stability). The `backbone` parameter allows you to choose between different ResNet architectures—use `resnet18` for faster training or `resnet101` for potentially better accuracy.
111
114
112
-
#### Step 4: Download Detection Weights
113
-
The inference pipeline uses a separate, pre-trained YOLO model for initial insect detection. You need to download its weights manually.
115
+
#### Step 4: Validate Model
116
+
Evaluate the trained model on a held-out validation set. This calculates precision, recall, and F1-score at all taxonomic levels.
114
117
115
-
You can download the weights file from [this link](https://github.com/Tvenver/Bplusplus/releases/download/v1.2.3/v11small-generic.pt).
Place it in the `trained_model` directory and ensure it is named `yolo_weights.pt`.
121
+
results = bplusplus.validate(
122
+
species_list=names,
123
+
validation_dir=PREPARED_DATA_DIR / "valid",
124
+
hierarchical_weights=HIERARCHICAL_MODEL_PATH,
125
+
img_size=640, # Must match training
126
+
batch_size=32,
127
+
backbone="resnet50", # Must match training
128
+
)
129
+
```
118
130
119
131
#### Step 5: Run Inference on Video
120
-
Process a video file to detect, classify, and track insects. The final output is an annotated video and a CSV file with aggregated results for each tracked insect.
132
+
Process a video file to detect, classify, and track insects using motion-based detection. The pipeline uses background subtraction (GMM) to detect moving insects, tracks them across frames, and classifies confirmed tracks.
133
+
134
+
**Output files generated in `output_dir`:**
135
+
- `{video}_annotated.mp4` - Video showing confirmed tracks with classifications
136
+
- `{video}_debug.mp4` - Debug video with motion mask and all detections
137
+
- `{video}_results.csv` - Aggregated results per confirmed track
138
+
- `{video}_detections.csv` - Frame-by-frame detection data
For advanced control over detection parameters, provide a YAML config file:
160
+
161
+
```python
162
+
results = bplusplus.inference(
163
+
...,
164
+
config="detection_config.yaml"
165
+
)
166
+
```
167
+
168
+
Download a template config from the [releases page](https://github.com/Tvenver/Bplusplus/releases). Parameters control cohesiveness filtering, shape filtering, tracking behavior, and path topology analysis for confirming insect-like movement.
169
+
140
170
### Customization
141
171
142
172
To train the model on your own set of insect species, you only need to change the `names` list in **Step 1**. The pipeline will automatically handle the rest.
@@ -168,8 +198,9 @@ names_with_unknown = [
168
198
The pipeline will create the following directories to store artifacts:
169
199
170
200
- `GBIF_data/`: Stores the raw images downloaded from GBIF.
171
-
- `prepared_data/`: Contains the cleaned, cropped, and resized images ready for training.
172
-
- `trained_model/`: Saves the trained model weights (`best_multitask.pt`) and pre-trained detection weights.
201
+
- `prepared_data/`: Contains the cleaned, cropped, and resized images ready for training (`train/` and optionally `valid/` subdirectories).
202
+
- `trained_model/`: Saves the trained model weights (`best_multitask.pt`).
203
+
- `output/`: Inference results including annotated videos and CSV files.
0 commit comments