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
This commit is contained in:
Rick McEwen
2025-12-31 17:42:52 -05:00
parent 41bc0c701f
commit 41c75356d9
2 changed files with 112 additions and 14 deletions

View File

@ -16,10 +16,19 @@ 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"
@ -31,7 +40,7 @@ echo " Seed: $SEED"
echo ""
# Test 1: Simple matching (baseline - all matches above threshold)
echo "=== Test 1: Simple matching (baseline) ===" | tee -a "$OUTPUT_FILE"
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 \
@ -39,13 +48,12 @@ uv run python "$SCRIPT_DIR/test_logo_detection.py" \
--negative-samples $NEGATIVE_SAMPLES \
--matching-method simple \
--seed $SEED \
2>&1 | tee -a "$OUTPUT_FILE"
--output-file "$OUTPUT_FILE"
echo "" >> "$OUTPUT_FILE"
echo "" >> "$OUTPUT_FILE"
echo ""
# Test 2: Margin-based matching
echo "=== Test 2: Margin-based matching ===" | tee -a "$OUTPUT_FILE"
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 \
@ -53,13 +61,12 @@ uv run python "$SCRIPT_DIR/test_logo_detection.py" \
--negative-samples $NEGATIVE_SAMPLES \
--matching-method margin \
--seed $SEED \
2>&1 | tee -a "$OUTPUT_FILE"
--output-file "$OUTPUT_FILE"
echo "" >> "$OUTPUT_FILE"
echo "" >> "$OUTPUT_FILE"
echo ""
# Test 3: Multi-ref with mean similarity
echo "=== Test 3: Multi-ref matching (mean similarity) ===" | tee -a "$OUTPUT_FILE"
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 \
@ -68,13 +75,12 @@ uv run python "$SCRIPT_DIR/test_logo_detection.py" \
--matching-method multi-ref \
--min-matching-refs $MIN_MATCHING_REFS \
--seed $SEED \
2>&1 | tee -a "$OUTPUT_FILE"
--output-file "$OUTPUT_FILE"
echo "" >> "$OUTPUT_FILE"
echo "" >> "$OUTPUT_FILE"
echo ""
# Test 4: Multi-ref with max similarity
echo "=== Test 4: Multi-ref matching (max similarity) ===" | tee -a "$OUTPUT_FILE"
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 \
@ -84,7 +90,7 @@ uv run python "$SCRIPT_DIR/test_logo_detection.py" \
--min-matching-refs $MIN_MATCHING_REFS \
--use-max-similarity \
--seed $SEED \
2>&1 | tee -a "$OUTPUT_FILE"
--output-file "$OUTPUT_FILE"
echo ""
echo "Results saved to: $OUTPUT_FILE"