Add margin check to multi-ref matching to reduce false positives
The multi-ref matching method was missing a margin check against other logos, causing excessive false positives. This fix adds: - margin parameter to find_best_match_multi_ref() that requires the best logo's score to exceed the second-best by a minimum margin - Test script now passes --margin to both matching methods - Updated documentation to reflect margin applies to both methods Also adds run_comparison_tests.sh to run all three matching methods and compare results.
This commit is contained in:
@ -231,7 +231,7 @@ def main():
|
||||
"--margin",
|
||||
type=float,
|
||||
default=0.05,
|
||||
help="Required margin between best and second-best match for 'margin' method (default: 0.05)",
|
||||
help="Required margin between best and second-best match (applies to both methods) (default: 0.05)",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--matching-method",
|
||||
@ -453,6 +453,7 @@ def main():
|
||||
similarity_threshold=args.threshold,
|
||||
min_matching_refs=args.min_matching_refs,
|
||||
use_mean_similarity=not args.use_max_similarity,
|
||||
margin=args.margin,
|
||||
)
|
||||
if match_result:
|
||||
label, similarity, num_matching = match_result
|
||||
@ -511,9 +512,8 @@ def main():
|
||||
print(f" CLIP similarity threshold: {args.threshold}")
|
||||
print(f" DETR confidence threshold: {args.detr_threshold}")
|
||||
print(f" Matching method: {args.matching_method}")
|
||||
if args.matching_method == "margin":
|
||||
print(f" Matching margin: {args.margin}")
|
||||
else: # multi-ref
|
||||
print(f" Matching margin: {args.margin}")
|
||||
if args.matching_method == "multi-ref":
|
||||
print(f" Min matching refs: {args.min_matching_refs}")
|
||||
print(f" Similarity aggregation: {'max' if args.use_max_similarity else 'mean'}")
|
||||
if args.seed is not None:
|
||||
|
||||
Reference in New Issue
Block a user