#!/bin/bash # Download free test images for SAM3 inference testing # Uses Wikimedia Commons images (public domain/CC0) set -e OUTPUT_DIR="assets/test_images" mkdir -p "$OUTPUT_DIR" echo "============================================================" echo "Downloading Test Images from Wikimedia Commons" echo "============================================================" echo "Output directory: $OUTPUT_DIR" echo "" # Array of Wikimedia Commons images (all public domain or CC0) declare -a images=( # Pothole images "https://upload.wikimedia.org/wikipedia/commons/thumb/e/e8/Pothole_in_Finland.jpg/1200px-Pothole_in_Finland.jpg|pothole_finland.jpg" "https://upload.wikimedia.org/wikipedia/commons/thumb/a/ac/Pothole_on_city_street.jpg/1200px-Pothole_on_city_street.jpg|pothole_city.jpg" "https://upload.wikimedia.org/wikipedia/commons/thumb/f/f8/Street_pothole.JPG/1200px-Street_pothole.JPG|pothole_street.jpg" # Road crack images "https://upload.wikimedia.org/wikipedia/commons/thumb/4/42/Asphalt_with_cracks.jpg/1200px-Asphalt_with_cracks.jpg|road_crack_asphalt.jpg" "https://upload.wikimedia.org/wikipedia/commons/thumb/c/c8/Crack_in_asphalt_pavement.jpg/1200px-Crack_in_asphalt_pavement.jpg|road_crack_pavement.jpg" # Clean road images "https://upload.wikimedia.org/wikipedia/commons/thumb/6/64/Asphalt_road_surface_texture_06.jpg/1200px-Asphalt_road_surface_texture_06.jpg|road_clean_01.jpg" "https://upload.wikimedia.org/wikipedia/commons/thumb/b/b8/Asphalt_road_surface_01.jpg/1200px-Asphalt_road_surface_01.jpg|road_clean_02.jpg" # Mixed damage images "https://upload.wikimedia.org/wikipedia/commons/thumb/d/d0/Damaged_road_surface.jpg/1200px-Damaged_road_surface.jpg|road_damaged_mixed.jpg" "https://upload.wikimedia.org/wikipedia/commons/thumb/3/3e/Pothole_and_cracks.jpg/1200px-Pothole_and_cracks.jpg|pothole_and_cracks.jpg" ) successful=0 failed=0 skipped=0 for image_spec in "${images[@]}"; do IFS='|' read -r url filename <<< "$image_spec" output_path="$OUTPUT_DIR/$filename" if [ -f "$output_path" ]; then echo "⏭️ Skipping $filename (already exists)" ((skipped++)) continue fi echo "📥 Downloading: $filename" echo " URL: $url" if wget -q --show-progress --timeout=30 -O "$output_path" "$url" 2>&1; then echo " ✅ Downloaded" ((successful++)) else echo " ❌ Failed" ((failed++)) rm -f "$output_path" fi # Be respectful to servers sleep 1 echo "" done echo "============================================================" echo "Download Summary" echo "============================================================" echo "Total images: ${#images[@]}" echo "Successful: $successful" echo "Skipped (already exists): $skipped" echo "Failed: $failed" echo "" if [ $successful -gt 0 ] || [ $skipped -gt 0 ]; then echo "✅ Test images ready in $OUTPUT_DIR" ls -lh "$OUTPUT_DIR" else echo "❌ No images downloaded successfully" exit 1 fi