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:
@ -78,6 +78,41 @@ match = detector.find_best_match(
|
||||
**Returns:**
|
||||
- Tuple of (label, similarity) for best match, or None if no match above threshold
|
||||
|
||||
#### `find_all_matches()` - Find all matching reference logos
|
||||
|
||||
Returns ALL logos that have at least one reference above the similarity threshold. Each unique logo appears once with its highest similarity score.
|
||||
|
||||
```python
|
||||
matches = detector.find_all_matches(
|
||||
detected_embedding,
|
||||
reference_embeddings,
|
||||
similarity_threshold=0.7
|
||||
)
|
||||
# Returns: [(label1, similarity1), (label2, similarity2), ...]
|
||||
```
|
||||
|
||||
**Parameters:**
|
||||
- `detected_embedding`: CLIP embedding from detected logo region
|
||||
- `reference_embeddings`: List of (label, embedding) tuples for reference logos
|
||||
- `similarity_threshold`: Minimum similarity to consider a match (0-1, default: 0.7)
|
||||
|
||||
**Returns:**
|
||||
- List of (label, similarity) tuples for all matches above threshold, sorted by similarity descending
|
||||
- Each logo appears at most once (with its highest matching reference)
|
||||
|
||||
**Example:**
|
||||
```python
|
||||
# Get all logos that match a detection
|
||||
all_matches = detector.find_all_matches(
|
||||
detection["embedding"],
|
||||
reference_embeddings,
|
||||
similarity_threshold=0.7
|
||||
)
|
||||
|
||||
for label, similarity in all_matches:
|
||||
print(f"Matched: {label} (similarity: {similarity:.3f})")
|
||||
```
|
||||
|
||||
#### `detect_and_match()` - One-step detection and matching
|
||||
|
||||
```python
|
||||
|
||||
Reference in New Issue
Block a user