A complete Python-based pipeline for detecting man-made anomalies in satellite imagery using hyperspectral and thermal data from Wyvern or USGS sources. SpecTect combines deep learning models with advanced spectral analysis to identify industrial activity, fires, pollution, and material signatures.
- Multi-Modal Analysis: Supports hyperspectral (400-2500 nm) and thermal infrared data
- Advanced Deep Learning: Autoencoders, VAEs, and Transformer models for anomaly detection
- Material Identification: Spectral signature matching with USGS Spectral Library integration
- Real-time Processing: Optimized for large satellite scenes with tiling support
- Rich Visualizations: Interactive maps, heatmaps, and detailed analytics
- Production Ready: CLI interface, configuration management, and comprehensive metrics
# Clone the repository
git clone <repository-url>
cd SpecTect
# Install dependencies
pip install -r requirements.txt
# Make CLI executable
chmod +x cli.py# Download sample data
python cli.py download-data --source wyvern --output ./data
# Detect anomalies
python cli.py detect-anomalies --input ./data/sample.tif --output ./results
# Identify materials
python cli.py identify-materials --input ./data/sample.tif --output ./materials
# Get dataset information
python cli.py info --input ./data/sample.tiffrom spectect import DataLoader, AnomalyDetector, MaterialClassifier
from spectect.visualization import AnomalyVisualizer
# Load hyperspectral data
loader = DataLoader()
data, metadata = loader.load_hyperspectral("satellite_image.tif")
# Detect anomalies
detector = AnomalyDetector(model_type="autoencoder")
detector.train_model(normal_data)
anomaly_scores, reconstructed = detector.detect_anomalies(data)
# Classify materials
classifier = MaterialClassifier()
material_map, confidence = classifier.classify_materials(data)
# Visualize results
visualizer = AnomalyVisualizer()
visualizer.create_anomaly_overlay(data, anomaly_scores)- Python 3.8+
- 8GB+ RAM (16GB+ recommended for large scenes)
- CUDA-compatible GPU (optional, for deep learning acceleration)
- Core: NumPy, SciPy, scikit-learn
- Geospatial: Rasterio, GeoPandas, GDAL
- Deep Learning: PyTorch, Transformers
- Visualization: Matplotlib, Plotly, Folium
- Spectral Analysis: Spectral Python
See requirements.txt for complete dependency list.
SpecTect/
βββ spectect/
β βββ data/ # Data access and management
β β βββ loader.py # Multi-format data loading
β β βββ usgs_client.py # USGS EarthExplorer API
β β βββ wyvern_client.py # Wyvern open data client
β β βββ dataset_manager.py # Dataset organization
β βββ models/ # Deep learning models
β β βββ anomaly_detector.py # Autoencoders, VAEs, Transformers
β β βββ material_classifier.py # Material identification
β β βββ thermal_models.py # Thermal-specific models
β βββ inference/ # Inference pipeline
β β βββ engine.py # Coordinated processing
β βββ visualization/ # Visualization tools
β β βββ anomaly_visualizer.py # Maps, overlays, dashboards
β βββ utils/ # Utilities
β βββ preprocessing.py # Data preprocessing
β βββ metrics.py # Evaluation metrics
β βββ config.py # Configuration management
βββ cli.py # Command-line interface
βββ requirements.txt # Dependencies
βββ examples/ # Example notebooks
Create a configuration file to customize SpecTect for your needs:
# Generate default configuration
python cli.py init-config --template development
# Edit spectect_config.json
{
"data": {
"cache_dir": "./cache",
"download_sample_data": true
},
"models": {
"default_anomaly_model": "autoencoder",
"use_pretrained": false
},
"training": {
"epochs": 100,
"batch_size": 32,
"learning_rate": 0.001
},
"inference": {
"anomaly_threshold": 0.5,
"confidence_threshold": 0.7
}
}- Hyperspectral: 224 bands, 400-2500 nm
- Thermal: 10 bands, 8000-14000 nm
- Format: GeoTIFF, HDF5
- Access: Public, no authentication required
- Landsat: Multispectral + thermal
- ASTER: VNIR + SWIR + TIR
- Format: GeoTIFF, HDF-EOS
- Access: Requires free USGS account
# USGS authentication
import os
os.environ['USGS_USERNAME'] = 'your_username'
os.environ['USGS_PASSWORD'] = 'your_password'
python cli.py download-data --source usgs- Best for: General-purpose anomaly detection
- Strengths: Fast training, good reconstruction
- Use case: Industrial activity, infrastructure changes
- Best for: Uncertainty-aware detection
- Strengths: Probabilistic outputs, handles noise
- Use case: Environmental monitoring, subtle changes
- Best for: Complex spatial-spectral patterns
- Strengths: Attention mechanism, contextual understanding
- Use case: Fire detection, vegetation stress
# Model comparison
for model_type in ['autoencoder', 'vae', 'transformer']:
detector = AnomalyDetector(model_type=model_type)
results = detector.detect_anomalies(data)
print(f"{model_type}: {results['anomaly_count']} anomalies detected")SpecTect uses spectral signature matching to identify materials:
- Urban: Concrete, asphalt, roofing materials
- Natural: Vegetation, water, soil types
- Industrial: Metals, chemicals, waste products
- Geological: Minerals, rock types
- USGS Spectral Library: 2000+ material signatures
- Custom Libraries: Upload your own reference spectra
- Adaptive Learning: Improve accuracy with local samples
# Custom spectral library
custom_library = {
"solar_panels": {
"wavelengths": [400, 450, ..., 2500],
"reflectance": [0.05, 0.08, ..., 0.15],
"description": "Crystalline silicon solar panels"
}
}
classifier = MaterialClassifier()
classifier.load_spectral_library(custom_library)- Pixel-level: Precision, Recall, F1-score, ROC-AUC
- Object-level: Detection rate, False alarm rate
- Spatial: Boundary accuracy, Object completeness
- Overall Accuracy: Correctly classified pixels
- Per-class Metrics: Producer's and User's accuracy
- Confusion Matrix: Detailed classification results
from spectect.utils import AnomalyMetrics, MaterialClassificationMetrics
# Evaluate anomaly detection
metrics = AnomalyMetrics()
scores = metrics.evaluate(predictions, ground_truth)
print(f"ROC-AUC: {scores['roc_auc']:.3f}")
# Evaluate material classification
mat_metrics = MaterialClassificationMetrics()
accuracy = mat_metrics.overall_accuracy(predicted, actual)- RGB composite with anomaly highlights
- Customizable color schemes and transparency
- Export to PNG, PDF, or GeoTIFF
- Web-based maps with Folium/Leaflet
- Zoom, pan, and layer control
- Popup information for anomalies
- Signature comparison charts
- Band-by-band analysis
- Material identification confidence
- Plotly-based interactive dashboards
- Real-time statistics and metrics
- Export capabilities
visualizer = AnomalyVisualizer()
# Create comprehensive visualization
visualizer.create_dashboard(
data=hyperspectral_data,
anomaly_scores=anomaly_results,
material_map=material_results,
save_path="dashboard.html"
)# Train custom anomaly detector
detector = AnomalyDetector(model_type="vae")
# Prepare training data
dataset_manager = DatasetManager()
train_patches = dataset_manager.create_training_patches(
"large_scene.tif", patch_size=(64, 64)
)
# Train model
history = detector.train_model(
train_data=train_patches,
epochs=200,
batch_size=32
)
# Save trained model
detector.save_model("custom_vae_model.pth")from spectect.inference import InferenceEngine
# Initialize with both hyperspectral and thermal data
engine = InferenceEngine()
# Fused anomaly detection
results = engine.detect_multimodal_anomalies(
hyperspectral_data=hs_data,
thermal_data=thermal_data,
fusion_method="late_fusion"
)# Process large scenes with tiling
large_scene = "landsat_scene.tif"
# Automatic tiling and processing
engine = InferenceEngine()
results = engine.process_large_scene(
large_scene,
tile_size=(1024, 1024),
overlap=0.1,
parallel=True
)# Run test suite
python -m pytest tests/
# Test specific module
python -m pytest tests/test_data_loader.py# Test full pipeline
python tests/integration/test_pipeline.py
# Benchmark performance
python tests/benchmark/performance_test.py- Synthetic anomaly injection
- Labeled validation scenes
- Cross-sensor comparison
We welcome contributions! Please see our Contributing Guidelines for details.
# Create development environment
python -m venv venv
source venv/bin/activate # Linux/Mac
# or
venv\Scripts\activate # Windows
# Install in development mode
pip install -e .
# Install development dependencies
pip install -r requirements-dev.txt
# Run pre-commit hooks
pre-commit installThis project is licensed under the MIT License - see the LICENSE file for details.
- Wyvern Earth: Open satellite data access
- USGS: Earth observation data and spectral libraries
- PyTorch Team: Deep learning framework
- GDAL/OGR: Geospatial data processing
- Open Source Community: Various dependencies and tools
- Documentation: https://spectect.readthedocs.io
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Email: [email protected]
- Real-time streaming data processing
- Google Earth Engine integration
- Advanced ensemble methods
- Mobile/edge deployment
- Synthetic data generation
- Active learning capabilities
- Multi-temporal analysis
- Cloud deployment templates
- 3D/volumetric analysis
- Federated learning support
- Automated report generation
- Enterprise features
SpecTect - Transforming satellite imagery into actionable intelligence π°οΈβ¨