Files
logo_test/run_comparison_tests.sh
Rick McEwen 41c75356d9 Add --output-file option for clean results output
- Add --output-file argument to test_logo_detection.py that appends
  only the results summary (no progress indicators) to specified file
- Add write_results_to_file() with detailed header showing test type
  and method parameters
- Update run_comparison_tests.sh to use --output-file instead of
  tee/redirection, keeping console output separate from file output
2025-12-31 17:42:52 -05:00

96 lines
3.0 KiB
Bash
Executable File

#!/bin/bash
#
# Run logo detection tests with all four matching methods and save results.
#
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
OUTPUT_FILE="${SCRIPT_DIR}/comparison_results.txt"
# Common parameters
NUM_LOGOS=20
REFS_PER_LOGO=10
POSITIVE_SAMPLES=20
NEGATIVE_SAMPLES=100
MIN_MATCHING_REFS=3
# Use a fixed seed for reproducibility across methods
SEED=42
# Clear output file and write header
echo "Logo Detection Comparison Tests" > "$OUTPUT_FILE"
echo "================================" >> "$OUTPUT_FILE"
echo "Date: $(date)" >> "$OUTPUT_FILE"
echo "" >> "$OUTPUT_FILE"
echo "Common Parameters:" >> "$OUTPUT_FILE"
echo " Reference logos: $NUM_LOGOS" >> "$OUTPUT_FILE"
echo " Refs per logo: $REFS_PER_LOGO" >> "$OUTPUT_FILE"
echo " Positive samples: $POSITIVE_SAMPLES" >> "$OUTPUT_FILE"
echo " Negative samples: $NEGATIVE_SAMPLES" >> "$OUTPUT_FILE"
echo " Min matching refs: $MIN_MATCHING_REFS" >> "$OUTPUT_FILE"
echo " Seed: $SEED" >> "$OUTPUT_FILE"
echo "" >> "$OUTPUT_FILE"
echo "Running tests with:"
echo " Reference logos: $NUM_LOGOS"
echo " Refs per logo: $REFS_PER_LOGO"
echo " Positive samples: $POSITIVE_SAMPLES"
echo " Negative samples: $NEGATIVE_SAMPLES"
echo " Min matching refs: $MIN_MATCHING_REFS"
echo " Seed: $SEED"
echo ""
# Test 1: Simple matching (baseline - all matches above threshold)
echo "=== Test 1: Simple matching (baseline) ==="
uv run python "$SCRIPT_DIR/test_logo_detection.py" \
--num-logos $NUM_LOGOS \
--refs-per-logo $REFS_PER_LOGO \
--positive-samples $POSITIVE_SAMPLES \
--negative-samples $NEGATIVE_SAMPLES \
--matching-method simple \
--seed $SEED \
--output-file "$OUTPUT_FILE"
echo ""
# Test 2: Margin-based matching
echo "=== Test 2: Margin-based matching ==="
uv run python "$SCRIPT_DIR/test_logo_detection.py" \
--num-logos $NUM_LOGOS \
--refs-per-logo $REFS_PER_LOGO \
--positive-samples $POSITIVE_SAMPLES \
--negative-samples $NEGATIVE_SAMPLES \
--matching-method margin \
--seed $SEED \
--output-file "$OUTPUT_FILE"
echo ""
# Test 3: Multi-ref with mean similarity
echo "=== Test 3: Multi-ref matching (mean similarity) ==="
uv run python "$SCRIPT_DIR/test_logo_detection.py" \
--num-logos $NUM_LOGOS \
--refs-per-logo $REFS_PER_LOGO \
--positive-samples $POSITIVE_SAMPLES \
--negative-samples $NEGATIVE_SAMPLES \
--matching-method multi-ref \
--min-matching-refs $MIN_MATCHING_REFS \
--seed $SEED \
--output-file "$OUTPUT_FILE"
echo ""
# Test 4: Multi-ref with max similarity
echo "=== Test 4: Multi-ref matching (max similarity) ==="
uv run python "$SCRIPT_DIR/test_logo_detection.py" \
--num-logos $NUM_LOGOS \
--refs-per-logo $REFS_PER_LOGO \
--positive-samples $POSITIVE_SAMPLES \
--negative-samples $NEGATIVE_SAMPLES \
--matching-method multi-ref \
--min-matching-refs $MIN_MATCHING_REFS \
--use-max-similarity \
--seed $SEED \
--output-file "$OUTPUT_FILE"
echo ""
echo "Results saved to: $OUTPUT_FILE"