Add simple matching method as baseline for comparison tests

- Add find_all_matches() method to DetectLogosDETR that returns all
  logos above similarity threshold without any rejection logic
- Add --matching-method simple option to test script
- Update run_comparison_tests.sh to include simple matching as Test 1
- Update documentation to describe simple matching method
This commit is contained in:
Rick McEwen
2025-12-31 17:36:18 -05:00
parent 197e007591
commit 41bc0c701f
5 changed files with 174 additions and 40 deletions

View File

@ -39,8 +39,8 @@ The system uses a two-stage pipeline:
| Parameter | Default | Description |
|-----------|---------|-------------|
| `--matching-method` | margin | Matching method: `margin` or `multi-ref` |
| `--margin` | 0.05 | Required margin between best and second-best match (applies to both methods) |
| `--matching-method` | margin | Matching method: `simple`, `margin`, or `multi-ref` |
| `--margin` | 0.05 | Required margin between best and second-best match (applies to `margin` and `multi-ref`) |
#### Multi-Ref Method Parameters (when `--matching-method multi-ref`)
@ -193,11 +193,11 @@ This ensures cosine similarity is computed correctly and scores fall in the rang
| Method | Test Script Option | Key Feature |
|--------|-------------------|-------------|
| `find_best_match` | N/A (library only) | Returns highest similarity above threshold |
| `find_all_matches` | `--matching-method simple` | Returns ALL logos above threshold (baseline, most permissive) |
| `find_best_match_with_margin` | `--matching-method margin` | Requires margin over second-best match |
| `find_best_match_multi_ref` | `--matching-method multi-ref` | Aggregates scores across reference images |
The test script supports both `margin` and `multi-ref` matching methods via the `--matching-method` parameter.
The test script supports `simple`, `margin`, and `multi-ref` matching methods via the `--matching-method` parameter.
---
@ -242,13 +242,14 @@ Input Image
┌─────────────────────────────────────┐
│ Matching (selectable method) │
│ ┌───────────────┬────────────────┐ │
│ │ margin │ multi-ref │ │
│ ├───────────────┼────────────────┤ │
│ │ Require margin│ Aggregate │ │
│ │ over 2nd best │ across refs │ │
│ │ match │ (mean or max) │ │
└───────────────┴────────────────┘
│ ┌─────────┬─────────┬────────────┐ │
│ │ simple │ margin │ multi-ref │ │
│ ├─────────┼─────────┼────────────┤ │
│ │ All │ Require │ Aggregate │ │
│ │ matches │ margin │ across │ │
│ │ above │ over │ refs │ │
│ thresh │ 2nd best│ (mean/max) │
│ └─────────┴─────────┴────────────┘ │
└─────────────────────────────────────┘
@ -259,6 +260,15 @@ Matched Logo Labels
## Tuning Recommendations
### For Simple Matching (`--matching-method simple`)
| Goal | Adjustments |
|------|-------------|
| **Reduce false positives** | Increase `--threshold` (only tuning option for simple method) |
| **Reduce false negatives** | Decrease `--threshold` |
Note: Simple matching is primarily used as a baseline. For production use, consider `margin` or `multi-ref`.
### For Margin-Based Matching (`--matching-method margin`)
| Goal | Adjustments |
@ -287,6 +297,9 @@ Matched Logo Labels
## Example Usage
```bash
# Simple matching (baseline - all matches above threshold)
python test_logo_detection.py -n 20 --matching-method simple --threshold 0.70
# Default margin-based matching
python test_logo_detection.py -n 20 --threshold 0.75 --margin 0.05