|
281 | 281 | "\n", |
282 | 282 | "Runs motion-based insect detection and hierarchical classification on video files. Detects moving insects using background subtraction (GMM), tracks them across frames, classifies each detection, and aggregates predictions per track.\n", |
283 | 283 | "\n", |
| 284 | + "**Note:** The species list and taxonomy are automatically loaded from the model checkpoint, so you don't need to provide them again.\n", |
| 285 | + "\n", |
284 | 286 | "**Output files generated:**\n", |
285 | 287 | "- `{video}_annotated.mp4` - Video with detection boxes and track paths (if `save_video=True`)\n", |
286 | 288 | "- `{video}_debug.mp4` - Side-by-side view with GMM motion mask (if `save_video=True`)\n", |
|
297 | 299 | "outputs": [], |
298 | 300 | "source": [ |
299 | 301 | "results = bplusplus.inference(\n", |
300 | | - " species_list=names,\n", |
301 | 302 | " hierarchical_model_path=RESNET_MULTITASK_WEIGHTS,\n", |
302 | 303 | " video_path=\"./10.mp4\",\n", |
303 | 304 | " output_dir=\"./output\",\n", |
| 305 | + " # species_list=names, # Optional: override species from checkpoint\n", |
304 | 306 | " fps=None, # None = all frames\n", |
305 | 307 | " backbone=\"resnet50\", # Must match training\n", |
306 | 308 | " save_video=True, # Set to False to skip video rendering (only CSV output)\n", |
| 309 | + " img_size=60, # Must match training\n", |
307 | 310 | ")\n", |
308 | 311 | "\n", |
309 | 312 | "print(f\"Detected {results['tracks']} tracks ({results['confirmed_tracks']} confirmed)\")" |
|
326 | 329 | ")\n", |
327 | 330 | "```\n", |
328 | 331 | "\n", |
| 332 | + "#### Full Configuration Parameters\n", |
| 333 | + "\n", |
329 | 334 | "| Parameter | Default | Description |\n", |
330 | 335 | "|-----------|---------|-------------|\n", |
| 336 | + "| **GMM Background Subtractor** | | *Motion detection model* |\n", |
| 337 | + "| `gmm_history` | 500 | Frames to build background model |\n", |
| 338 | + "| `gmm_var_threshold` | 16 | Variance threshold for foreground detection |\n", |
| 339 | + "| **Morphological Filtering** | | *Noise removal* |\n", |
| 340 | + "| `morph_kernel_size` | 3 | Morphological kernel size (NxN) |\n", |
331 | 341 | "| **Cohesiveness** | | *Filters scattered motion (plants) vs compact motion (insects)* |\n", |
332 | 342 | "| `min_largest_blob_ratio` | 0.80 | Min ratio of largest blob to total motion |\n", |
333 | 343 | "| `max_num_blobs` | 5 | Max separate blobs allowed in detection |\n", |
| 344 | + "| `min_motion_ratio` | 0.15 | Min ratio of motion pixels to bbox area |\n", |
334 | 345 | "| **Shape** | | *Filters by contour properties* |\n", |
335 | 346 | "| `min_area` | 200 | Min detection area (px²) |\n", |
336 | 347 | "| `max_area` | 40000 | Max detection area (px²) |\n", |
|
340 | 351 | "| `min_displacement` | 50 | Min net movement for confirmation (px) |\n", |
341 | 352 | "| `min_path_points` | 10 | Min points before path analysis |\n", |
342 | 353 | "| `max_frame_jump` | 100 | Max jump between frames (px) |\n", |
343 | | - "| `lost_track_seconds` | 1.5 | How long to remember lost tracks (s) |\n", |
| 354 | + "| `max_lost_frames` | 45 | Frames before lost track deleted (e.g., 45 @ 30fps = 1.5s) |\n", |
| 355 | + "| `max_area_change_ratio` | 3.0 | Max area change ratio between frames |\n", |
| 356 | + "| **Tracker Matching** | | *Hungarian algorithm cost function* |\n", |
| 357 | + "| `tracker_w_dist` | 0.6 | Weight for distance cost (0-1) |\n", |
| 358 | + "| `tracker_w_area` | 0.4 | Weight for area cost (0-1) |\n", |
| 359 | + "| `tracker_cost_threshold` | 0.3 | Max cost for valid match (0-1) |\n", |
344 | 360 | "| **Path Topology** | | *Confirms insect-like movement patterns* |\n", |
345 | 361 | "| `max_revisit_ratio` | 0.30 | Max ratio of revisited positions |\n", |
346 | 362 | "| `min_progression_ratio` | 0.70 | Min forward progression |\n", |
347 | 363 | "| `max_directional_variance` | 0.90 | Max heading variance |\n", |
| 364 | + "| `revisit_radius` | 50 | Radius (px) for revisit detection |\n", |
348 | 365 | "\n" |
349 | 366 | ] |
350 | 367 | } |
|
0 commit comments