Skip to content

Tushar-Surti/SolarScope

Repository files navigation

☀️ SolarScope

SolarScope Logo

Illuminating the Future of Renewable Energy

Python PyTorch Flask License

Transforming satellite imagery into actionable solar energy insights using cutting-edge AI

Watch Demo

🚀 Quick Start📖 Documentation🎯 Features🤝 Contributing


🌟 What is SolarScope?

SolarScope is an intelligent, AI-powered web application that revolutionizes solar energy assessment by automatically detecting:

  • 🏗️ Buildings & Rooftops from satellite/aerial imagery
  • ☀️ Existing Solar Panels on detected structures
  • 📊 Installation Potential for renewable energy deployment

Using a sophisticated dual-model sequential pipeline, SolarScope combines DeepLab V3+ semantic segmentation with Faster R-CNN object detection to deliver precise, actionable insights for solar energy planning.

graph LR
    A[📤 Upload Image] -->|🔍| B[Building Detection]
    B -->|✅ Found| C[Solar Panel Detection]
    B -->|❌ None| D[Stop]
    C --> E[📊 Generate Report]
    style A fill:#4CAF50,stroke:#333,stroke-width:2px,color:#fff
    style B fill:#2196F3,stroke:#333,stroke-width:2px,color:#fff
    style C fill:#FF9800,stroke:#333,stroke-width:2px,color:#fff
    style E fill:#9C27B0,stroke:#333,stroke-width:2px,color:#fff
Loading

✨ Features

🤖 AI-Powered Detection

  • DeepLab V3+ with ResNet-50 backbone
  • Faster R-CNN for solar panel identification
  • Sequential pipeline optimization
  • Real-time confidence scoring

🎨 Modern Interface

  • Drag & drop file upload
  • Live progress indicators
  • Interactive visualizations
  • Responsive design

📊 Comprehensive Analytics

  • Building coverage statistics
  • Solar panel count & locations
  • GeoJSON export capability
  • Detailed confidence metrics

🚀 Production Ready

  • RESTful API endpoints
  • Health monitoring
  • Error handling
  • Scalable architecture

🏗️ Architecture

🔄 Detection Pipeline

┌──────────────┐
│ Upload Image │
│   📷 .tif    │
└──────┬───────┘
       │
       ▼
┌──────────────────┐
│ Building Detect  │
│  DeepLab V3+     │
└──────┬───────────┘
       │
       ├─────► Buildings Found? ──NO──► ❌ Stop
       │
       YES
       ▼
┌──────────────────┐
│ Solar Panel Det  │
│  Faster R-CNN    │
└──────┬───────────┘
       │
       ▼
┌──────────────────┐
│  📊 Results &    │
│   GeoJSON Export │
└──────────────────┘

🧠 AI Models

Model Purpose Architecture Output
DeepLab V3+ Building Segmentation ResNet-50 Backbone Binary Mask (256×256)
Faster R-CNN Solar Panel Detection Object Detection Bounding Boxes + GeoJSON

📁 Project Structure

SolarScope/
│
├── 🎯 app.py                      # Flask application server
├── 🧠 models_module.py            # AI model inference engine
├── ⚙️  config.py                   # Configuration & settings
├── 📋 requirements.txt            # Dependencies
├── 📖 README.md                   # Documentation (you are here!)
├── 🚫 .gitignore                  # Git exclusions
│
├── 🤖 models/                     # Pre-trained model weights
│   ├── deeplabv3plus_buildings_state_*.pth
│   └── best_model.pth
│
├── 📂 static/
│   ├── 📤 uploads/               # User uploaded images
│   └── 📊 results/               # Detection outputs & GeoJSON
│
├── 🎨 templates/
│   ├── index.html                # Main web interface
│   └── about.html                # About page
│
└── 📓 Deeplab V3+_train/         # Training notebooks
    └── deeplab_v3_building_detection.ipynb

🚀 Installation

Prerequisites: Python 3.8+ | pip | Git

📦 Quick Start

Windows (PowerShell)
# 1️⃣ Clone the repository
git clone https://github.com/Tushar-Surti/SolarScope.git
cd SolarScope

# 2️⃣ Create virtual environment
python -m venv venv
.\venv\Scripts\Activate.ps1

# 3️⃣ Install dependencies
pip install -r requirements.txt

# 4️⃣ Download pre-trained models
# Download from: https://drive.google.com/drive/folders/1Z471pir3Q7x096WscPsXnW3hgyMEmqk0
# Place in models/ directory

# 5️⃣ Verify installation
python config.py

# 6️⃣ Launch application
python app.py
Linux / macOS
# 1️⃣ Clone the repository
git clone https://github.com/Tushar-Surti/SolarScope.git
cd SolarScope

# 2️⃣ Create virtual environment
python3 -m venv venv
source venv/bin/activate

# 3️⃣ Install dependencies
pip install -r requirements.txt

# 4️⃣ Download pre-trained models (we have already trained it on our system,if you want to train it yourself you can run the training notebooks)
# Download from: https://drive.google.com/drive/folders/1Z471pir3Q7x096WscPsXnW3hgyMEmqk0
# Place in models/ directory

# 5️⃣ Verify installation
python config.py

# 6️⃣ Launch application
python app.py

🤖 Model Setup

# Download models from Google Drive
# https://drive.google.com/drive/folders/1Z471pir3Q7x096WscPsXnW3hgyMEmqk0

# Expected files in models/ directory:
# ├── deeplabv3plus_buildings_state_20250930_021413.pth
# └── best_model.pth

🎉 Ready to Go! Visit http://localhost:5000 in your browser


🎮 Usage Guide

🌐 Starting the Server

python app.py
# 🚀 Server running at http://localhost:5000

📸 Detection Workflow

1️⃣ Upload Image
• Drag & drop or click to browse
• Supported: PNG, JPG, TIFF, GeoTIFF
Recommended: GeoTIFF for geo-referencing
2️⃣ Configure Detection
• Adjust confidence thresholds (optional)
• Set window size & overlap for large images
• Review detection parameters
3️⃣ Run Sequential Detection
• Click "Start Sequential Detection"
• Watch real-time progress indicators
• Phase 1: Building detection → Phase 2: Solar panels
4️⃣ Analyze Results
• View segmentation masks & overlays
• Examine detected solar panels
• Download GeoJSON files
• Review statistics & metrics
5️⃣ Export & Share
• Download visualization images
• Export GeoJSON for GIS applications
• Save TIFF masks for further analysis

📊 Detection Outputs

🏗️ Building Detection Results

Output Description Format
🎭 Segmentation Mask Binary mask highlighting buildings PNG
🔴 Overlay Image Buildings highlighted in red on original PNG
📈 Statistics Coverage %, confidence, pixel counts JSON
📐 Dimensions Image resolution & processing details JSON

☀️ Solar Panel Detection Results

Output Description Format
📦 Bounding Boxes Detected panel locations with labels PNG
🗺️ GeoJSON Vectorized polygons with coordinates GeoJSON
📋 Panel List Individual detections with confidence JSON
🎯 TIFF Masks Geo-referenced detection masks TIFF
📊 Count & Stats Total panels & area coverage JSON

📝 Example Output Structure

{
  "success": true,
  "building_detection": {
    "detected": true,
    "coverage_percentage": 32.5,
    "confidence": 0.92,
    "building_pixels": 84832
  },
  "solar_panel_detection": {
    "detected": true,
    "count": 12,
    "avg_confidence": 0.87,
    "geojson_path": "/static/results/solar_panels.geojson"
  }
}

⚙️ Configuration

Customize detection parameters in config.py:

# 🎯 Detection Thresholds
BUILDING_DETECTION_THRESHOLD = 1.0       # Minimum building coverage (%)
BUILDING_CONFIDENCE_THRESHOLD = 0.5      # Minimum confidence score
SOLAR_PANEL_CONFIDENCE_THRESHOLD = 0.5   # Panel detection threshold

# 🔧 Processing Parameters
SOLAR_PANEL_WINDOW_SIZE = 512            # Detection window size
SOLAR_PANEL_OVERLAP = 256                # Overlap between windows
MAX_VISUALIZATION_DIMENSION = 2048       # Max image size for display

# 🖥️ Server Settings
DEFAULT_PORT = 5000                      # Flask server port
DEBUG_MODE = True                        # Enable debug logging
DEVICE = 'cuda'                          # 'cuda' or 'cpu'

🐛 Troubleshooting

❌ Model Not Loading
# Verify model files exist
ls models/

# Check PyTorch installation
python -c "import torch; print(torch.__version__)"

# Ensure correct file names in config.py
# Expected: deeplabv3plus_buildings_state_*.pth and best_model.pth
⚠️ Solar Panel Detection Not Working
  • ✅ Ensure input image is GeoTIFF format
  • ✅ Verify geoai library is installed: pip show geoai
  • ✅ Check model path in configuration
  • ✅ Ensure buildings were detected in Phase 1
💾 Out of Memory Errors
# In config.py, reduce these values:
SOLAR_PANEL_WINDOW_SIZE = 256  # Default: 512
MAX_VISUALIZATION_DIMENSION = 1024  # Default: 2048

# Or force CPU usage:
DEVICE = 'cpu'  # Default: 'cuda'
📦 Import Errors
# Reinstall all dependencies
pip install -r requirements.txt --force-reinstall

# For geoai specifically
pip install geoai --upgrade

# Verify installations
pip list | grep -E "torch|flask|geoai"
🌐 Server Won't Start
  • Check port 5000 is not in use: netstat -ano | findstr :5000
  • Try different port in config.py: DEFAULT_PORT = 8000
  • Check firewall settings
  • Ensure virtual environment is activated

🔌 API Reference

POST /detect

Performs sequential building and solar panel detection.

Request:

POST /detect HTTP/1.1
Content-Type: multipart/form-data

file: <image_file>
confidence_threshold: 0.5 (optional)
window_size: 512 (optional)
overlap: 256 (optional)

Response:

{
  "success": true,
  "original_image": "/static/uploads/image.tif",
  "building_detection": {
    "detected": true,
    "prediction_mask": "/static/results/mask.png",
    "overlay_image": "/static/results/overlay.png",
    "statistics": {
      "coverage_percentage": 25.3,
      "confidence": 0.89
    }
  },
  "solar_panel_detection": {
    "detected": true,
    "count": 8,
    "detections": [...],
    "visualization": "/static/results/panels.png",
    "geojson": "/static/results/panels.geojson"
  }
}

GET /health

Health check endpoint for monitoring.

Response:

{
  "status": "healthy",
  "building_model_loaded": true,
  "solar_panel_model_loaded": true,
  "device": "cuda",
  "version": "1.0.0"
}

🔬 Technical Details

🏗️ Building Detection Model
  • Architecture: DeepLab V3+ with ResNet-50 backbone
  • Framework: PyTorch
  • Input Size: 256×256 RGB images
  • Output: Binary segmentation mask (building/background)
  • Training: Custom dataset with building annotations
  • Threshold: 1% building coverage to trigger solar detection
  • Preprocessing: Resize, normalize, tensor conversion
☀️ Solar Panel Detection Model
  • Architecture: Faster R-CNN
  • Framework: PyTorch with geoai wrapper
  • Input: GeoTIFF images (variable resolution)
  • Processing: Sliding window (512×512) with 256px overlap
  • Output: Bounding boxes + confidence scores + GeoJSON polygons
  • Post-processing: Non-maximum suppression, coordinate transformation
  • Geo-referencing: Maintains spatial coordinates in output
⚡ Performance Optimization
  • GPU Acceleration: CUDA support for faster inference
  • Batch Processing: Efficient window-based detection
  • Memory Management: Dynamic image resizing for large files
  • Caching: Model weights loaded once at startup
  • Asynchronous I/O: Non-blocking file operations

📄 License

This project combines functionalities from two separate detection systems. Ensure you have appropriate licenses for both models and the geoai library.

🤝 Contributing

We welcome contributions! Here's how you can help:


Code Improvements
Optimize algorithms
Add new features
Fix bugs

Documentation
Improve guides
Add tutorials
Write examples

Testing
Report issues
Test edge cases
Validate results

🎯 Areas for Improvement

  • 🔋 Add support for batch processing multiple images
  • 📊 Implement model versioning and A/B testing
  • 🎨 Enhanced visualization with 3D building models
  • 🗺️ Integration with mapping APIs (Google Maps, Mapbox)
  • 📱 Mobile-responsive UI improvements
  • 🔄 Real-time model retraining pipeline
  • 📈 Advanced analytics dashboard
  • 🌍 Multi-language support

📝 Contribution Guidelines

  1. 🍴 Fork the repository
  2. 🌿 Create a feature branch: git checkout -b feature/amazing-feature
  3. 💾 Commit changes: git commit -m 'Add amazing feature'
  4. 📤 Push to branch: git push origin feature/amazing-feature
  5. 🎉 Open a Pull Request

� License

This project is licensed under the MIT License - see the LICENSE file for details.


🙏 Acknowledgments

Built with ❤️ and powered by:

PyTorch Flask OpenCV NumPy

Special Thanks To

  • 🎓 DeepLab V3+ - for semantic segmentation architecture
  • 🔍 Faster R-CNN - for object detection framework
  • 📦 geoai - Geospatial AI library for solar panel detection
  • 🌍 PyTorch Team - For the amazing deep learning framework
  • 🎨 Icons8 - For beautiful 3D icons

🌟 Star this repo if you find it useful! 🌟

Made with 💚 for a sustainable future

Empowering renewable energy decisions through artificial intelligence


SolarScope © 2026 | Documentation | Report Bug | Request Feature


⚠️ Important Notice

This project is for educational and research purposes only.
Commercial use or public deployment of this software requires explicit written permission from the author.
Unauthorized commercial or public use is strictly prohibited.

About

Web-based system identifying rooftops suitable for solar panel installation using satellite imagery and deep learning.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages