An integrated pipeline for evaluating the importance of visual cues in geolocation tasks using the Cityscapes dataset. This pipeline orchestrates binary mask generation, image processing, visual cue removal using CLIPAway, and geolocation evaluation to systematically assess how removing specific visual features affects GPT's geolocation accuracy.
The pipeline consists of 7 main phases:
- Dataset Discovery - Find and validate image/annotation/GPS triplets
- Image Selection - Systematically select images for processing
- Mask Generation - Create binary masks for visual features
- Image Processing - Split and downscale images to 512x512
- CLIPAway Processing - Remove visual cues using AI inpainting
- Evaluation - Test geolocation accuracy with GPT vision models
- Report Generation - Generate comprehensive analysis reports
- Optimized Data Flow: Eliminates redundant file operations through ordered processing
- Resume Capability: Handle interruptions and continue from last checkpoint
- Systematic Selection: Deterministic image selection for reproducible results
- Ground Truth Integration: Uses actual GPS coordinates from Cityscapes vehicle data
- Comprehensive Testing: Full test suite with mock adapters for development
- Flexible Configuration: YAML-based configuration with command-line overrides
- Performance Monitoring: Resource usage tracking and time estimation
- Python 3.8+
- Required packages:
torch,torchvision,PIL,cv2,numpy,yaml,aiohttp - Optional: GPU with CUDA support for faster CLIPAway processing
- OpenAI API key for geolocation evaluation
-
Install Dependencies:
pip install torch torchvision Pillow opencv-python numpy PyYAML aiohttp psutil pip install diffusers # For CLIPAway -
Set Environment Variables:
export OPENAI_API_KEY="your-openai-api-key" export CITYSCAPES_DATASET="/path/to/cityscapes"
-
Download CLIPAway Models (if using actual CLIPAway):
cd CLIPAway bash download_pretrained_models.sh
The pipeline uses YAML configuration files. See config/pipeline_config.yaml for the main configuration and config/test_config.yaml for testing.
dataset:
cityscapes_root: "/path/to/cityscapes"
images_per_city: 5
cities: ["aachen", "bochum", "bremen"]
features:
target_features: ["human", "vehicle", "construction", "nature"]
evaluation:
model: "gpt-4-vision-preview"
concurrent_requests: 3
use_ground_truth: true# Run with default configuration
python run_pipeline.py
# Run with custom configuration
python run_pipeline.py --config config/pipeline_config.yaml
# Resume interrupted execution
python run_pipeline.py --config config/pipeline_config.yaml --resume
# Test run with limited images
python run_pipeline.py --config config/test_config.yaml --max-images 5# Configuration
--config PATH Configuration file path
--features LIST Override target features (comma-separated)
--cities LIST Override cities to process
--max-images N Limit total images processed
# Execution
--resume Resume from previous state
--validate-only Only validate setup
--dry-run Simulate execution without processing
# Output
--output-dir PATH Override output directory
--log-level LEVEL Set logging level (DEBUG, INFO, WARNING, ERROR)
--quiet Suppress console output# Full evaluation with all default features
python run_pipeline.py --config config/pipeline_config.yaml --features "human,vehicle,construction,nature"
# Quick test with mock evaluation
python run_pipeline.py --config config/test_config.yaml --mock-evaluation --max-images 3
# Process specific cities only
python run_pipeline.py --cities "aachen,bremen" --images-per-city 3
# Validate setup without running
python run_pipeline.py --validate-onlycore/visual_cue_pipeline.py- Main pipeline orchestratorcore/pipeline_dataset.py- Dataset discovery and managementcore/pipeline_config.py- Configuration systemcore/pipeline_state.py- State management and resume capabilitycore/pipeline_utils.py- Utility functions and helpers
adapters/mask_generator.py- Binary mask generation (wrapscreateBinaryMasks.py)adapters/image_processor.py- Image processing (wrapsimage_processor.py)adapters/clipaway_adapter.py- CLIPAway integrationadapters/evaluator_adapter.py- Geolocation evaluation
Original Images + Annotations + GPS Data
↓
Dataset Discovery & Selection
↓
Binary Mask Generation (per feature)
↓
Image Processing (split to 512x512)
↓
CLIPAway Processing (remove visual cues)
↓
Geolocation Evaluation (compare accuracy)
↓
Results Analysis & Reporting
The pipeline includes a comprehensive test suite:
# Run all tests
python tests/run_all_tests.py
# Run specific test categories
python tests/run_all_tests.py --category dataset
python tests/run_all_tests.py --category adapters
python tests/run_all_tests.py --category pipeline
# Run with verbose output
python tests/run_all_tests.py --verbose
# Fast testing (skip slow integration tests)
python tests/run_all_tests.py --fast- Pipeline Tests - End-to-end integration tests
- Dataset Tests - Dataset discovery and selection validation
- Adapter Tests - Component integration tests
- Component Tests - Individual component functionality
pipeline/output/
├── masks/ # Generated binary masks
│ ├── human/
│ ├── vehicle/
│ └── ...
├── processed/ # Split and downscaled images
│ ├── original/
│ ├── human/
│ └── ...
├── clipaway_results/ # Images with visual cues removed
│ ├── human/
│ ├── vehicle/
│ └── ...
├── evaluation_results/ # Geolocation evaluation data
│ ├── evaluation_results.db
│ ├── evaluation_results.json
│ └── evaluation_summary.txt
├── pipeline_report.json # Comprehensive execution report
├── pipeline_config_used.yaml
└── pipeline_state.json # Resume state
- Ordered Processing: Files processed in predetermined order
- Batch Operations: Process multiple items simultaneously
- Smart Caching: Avoid redundant file operations
- Memory Management: Stream processing for large datasets
- Model Reuse: CLIPAway models loaded once and reused
- Memory Monitoring: Track GPU memory usage
- Batch Size Optimization: Automatic batch sizing based on available memory
- Concurrent Requests: Multiple GPT API calls in parallel
- Response Caching: Cache geolocation predictions
- Rate Limiting: Respect API rate limits
The pipeline supports resuming interrupted executions:
- State Persistence: Automatically saves progress after each phase
- Smart Recovery: Identifies completed work and continues from interruption point
- Validation: Verifies existing outputs before resuming
- Progress Reporting: Shows detailed resume information
# Resume interrupted pipeline
python run_pipeline.py --resume
# View resume status
python run_pipeline.py --validate-only # Shows current state- Graceful Degradation: Continue processing when individual items fail
- Comprehensive Logging: Detailed error reporting and debugging info
- Validation Gates: Validate inputs before each processing phase
- Recovery Strategies: Multiple fallback options for common failures
- Visual Features: Add to
config/pipeline_config.yamltarget_featureslist - Selection Methods: Extend
PipelineDataset.select_images_per_city() - Evaluation Models: Add support in
EvaluatorAdapter - New Phases: Add to
PipelinePhaseenum and implement in orchestrator
- Create test class in appropriate
tests/test_*.pyfile - Add mock data generation methods
- Test both success and failure cases
- Include in
tests/run_all_tests.py
- Add new section to configuration dataclasses in
pipeline_config.py - Update validation methods
- Add command-line overrides if needed
- Update documentation
"No valid items selected"
- Check dataset paths in configuration
- Verify image/annotation/GPS file alignment
- Ensure GPS files contain valid coordinates
"CLIPAway model loading failed"
- Download required models:
bash CLIPAway/download_pretrained_models.sh - Check GPU memory availability
- Try CPU mode:
--device cpu
"API rate limit exceeded"
- Reduce
concurrent_requestsin configuration - Enable response caching:
cache_responses: true - Use mock mode for testing:
--mock-evaluation
"Pipeline validation failed"
- Run
--validate-onlyto see specific issues - Check Python version (3.8+ required)
- Verify all dependencies are installed
Slow processing:
- Enable GPU processing for CLIPAway
- Increase batch sizes if memory allows
- Use SSD storage for faster I/O
- Enable intermediate file cleanup
Memory issues:
- Reduce batch sizes
- Process fewer images per run
- Enable cleanup of intermediate files
- Monitor with
pipeline_utils.monitor_system_resources()
- Code Style: Follow existing patterns and naming conventions
- Testing: Add tests for new functionality
- Documentation: Update README and docstrings
- Configuration: Ensure new features are configurable
This pipeline integrates with the Cityscapes dataset and existing tools. Please ensure compliance with their respective licenses and usage terms.
- Cityscapes dataset team for the comprehensive urban scene dataset
- CLIPAway authors for the visual cue removal methodology
- OpenAI for the GPT vision models used in evaluation