Skip to main content

DEVISE - Depth-Aware Vegetation Indexing System

Python Version License: MIT Paper

DEVISE (Depth-Aware Vegetation Indexing System) is a comprehensive Python package for vegetation analysis that combines semantic segmentation with depth estimation to provide accurate vegetation indexing. The system leverages state-of-the-art deep learning models to identify and quantify vegetation coverage in images while incorporating depth information for enhanced analysis. Applied to 1,441,746 panoramas collected every 20 m along the road networks of 60 U.S. swing counties (2004-2024), DEVISE produces the first county-month panel of street-level greenness spanning two decades.

Research Paper

This package implements the methodology described in our research paper: "DEVISE: Depth-Aware Vegetation Indexing System"

Read the full paper on SSRN →

Examples

Below are sample images processed using the DEVISE system:

Test Sample 1

Test Sample 1

Test Sample 2

Test Sample 2

Test Sample 4

Test Sample 4

Test Sample 5

Test Sample 5

Test Sample 6

Test Sample 6

Test Sample 7

Test Sample 7

Test Sample 8

Test Sample 8

Installation

# Clone the repository
git clone https://github.com/NNyarlathotep/DEVISE.git
cd devise-pkg

# Install the package
pip install -e .

Quick Start

Complete Pipeline with Depth Analysis

import devise

# Run the complete DEVISE pipeline
devise.run_complete_pipeline(
    raw_folder="raw_images",           # Input images
    resized_folder="resized",          # Preprocessed images
    mask_folder="masks",               # Segmentation masks
    depth_mask_folder="depth_masks",   # Depth data (.npy files)
    depth_image_folder="depth_images", # Depth visualizations
    result_folder="results",           # Final combined results
    gvi_db_path="gvi.db",             # GVI database
    depth_db_path="depth_gvi.db"      # Depth-weighted GVI database
)

Quick Analysis Without Depth

import devise

# For faster processing without depth analysis
devise.quick_vegetation_analysis(
    raw_folder="raw_images",
    output_folder="output",
    db_path="results.db"
)

Individual Module Usage

import devise

# Step-by-step processing with new function names

# 1. Vegetation segmentation and GVI calculation
devise.run_vegetation_analysis_pipeline(
    "raw_images", "resized", "masks", "gvi.db"
)

# 2. Depth map generation
devise.generate_depth_maps_batch(
    "resized", "depth_masks", "depth_images"
)

# 3. Depth-weighted GVI calculation
devise.compute_depth_weighted_gvi_batch(
    "masks", "depth_masks", "depth_gvi.db"
)

# 4. Generate visualization overlays
devise.generate_visualization_batch(
    "resized", "masks", "results"
)

Advanced Usage

import devise
import numpy as np

# Process a single image with custom parameters
devise.create_vegetation_overlay(
    image_path="image.jpg",
    mask_npy_path="mask.npy", 
    output_path="result.jpg",
    alpha=0.6  # Adjust transparency
)

# Estimate depth for a single image
devise.estimate_depth_for_image(
    image_path="image.jpg",
    depth_npy_output_path="depth.npy",
    depth_vis_output_path="depth_vis.jpg"
)

# Calculate depth-weighted GVI for custom data
mask = np.load("vegetation_mask.npy")
depth = np.load("depth_map.npy")
tree_gvi = devise.calculate_depth_weighted_gvi(mask[:,:,0], depth)
grass_gvi = devise.calculate_depth_weighted_gvi(mask[:,:,1], depth)
plant_gvi = devise.calculate_depth_weighted_gvi(mask[:,:,2], depth)

# Database operations
conn = devise.initialize_gvi_database("custom.db")
devise.save_gvi_to_database(conn, "image_001", 0.65, 0.23, 0.12, 1.0)
conn.close()

API Reference

Main Pipeline Functions

  • run_complete_pipeline(...) - Execute full DEVISE workflow with depth analysis
  • quick_vegetation_analysis(...) - Fast vegetation analysis without depth
  • run_vegetation_analysis_pipeline(...) - Segmentation and GVI calculation
  • generate_depth_maps_batch(...) - Batch depth estimation
  • compute_depth_weighted_gvi_batch(...) - Batch depth-weighted GVI
  • generate_visualization_batch(...) - Batch visualization generation

Core Analysis Functions

  • segment_vegetation_and_calculate_gvi(...) - Segment single image and compute GVI
  • compute_vegetation_indices(...) - Calculate GVI from mask
  • calculate_depth_weighted_gvi(...) - Compute depth-weighted GVI
  • create_vegetation_overlay(...) - Create visualization overlay

Image Processing Functions

  • preprocess_image(...) - Remove borders and resize image
  • apply_vegetation_color_filter(...) - Apply HSV filtering
  • estimate_depth_for_image(...) - Estimate depth for single image

Database Functions

  • initialize_gvi_database(...) - Create/connect to GVI database
  • save_gvi_to_database(...) - Save GVI results to database
  • init_depth_gvi_db(...) - Initialize depth-weighted GVI database
  • save_depth_gvi_results(...) - Save depth GVI results

Package Structure

devise/
├── combine.py          # Image overlay and visualization generation
├── depth.py           # Monocular depth estimation using DPT
├── depth_combine.py    # Depth-weighted GVI calculation
├── pipeline.py         # Main segmentation and GVI pipeline
├── print_gvi.py       # Database query utilities for standard GVI
├── print_gvi_with_depth.py  # Database query utilities for depth GVI
└── __init__.py         # Package entry point with convenience functions

Models Used

  • Segmentation: facebook/mask2former-swin-large-ade-semantic
  • Depth Estimation: Intel/dpt-large

Both models are automatically downloaded from Hugging Face Hub on first use.

Output Format

Database Schema

The system stores results in SQLite databases with the following structure:

CREATE TABLE gvi (
    image_id TEXT PRIMARY KEY,
    tree_gvi REAL,      -- Green Vegetation Index for trees
    grass_gvi REAL,     -- Green Vegetation Index for grass  
    plant_gvi REAL,     -- Green Vegetation Index for plants
    total_gvi REAL      -- Combined vegetation index
);

File Outputs

  • Segmentation masks: .npy files with per-pixel class predictions (3 channels: trees, grass, plants)
  • Depth maps: .npy files with normalized depth values [0, 1]
  • Visualizations: .jpg overlay images showing segmentation results
  • Databases: .db files with GVI measurements

Requirements

  • Python 3.12+
  • PyTorch 1.9+
  • Transformers 4.15+
  • OpenCV 4.5+
  • NumPy 1.21+
  • Pillow 8.0+

License

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

Author

Cantay Caliskan Email: ccaliska@ur.rochester.edu

Zhizhuang Chen
Email: zchen141@u.rochester.edu

Junjie Zhao Email: jzhao58@u.rochester.edu

Linglan Yang Email: lyang49@u.rochester.edu

Mingzhen Zhang Email: mzhang96@u.rochester.edu

Metadata

Release files for devise-greenness 1.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for devise-greenness 1.0.3
File Size Uploaded Provenance Actions
devise_greenness-1.0.3.tar.gz 4.7 MB Without provenance Details for devise_greenness-1.0.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for devise-greenness 1.0.3
File Interpreter ABI Platform Actions
devise_greenness-1.0.3-py3-none-any.whl Python 3 none any Details for devise_greenness-1.0.3-py3-none-any.whl

Total release size: 4.7 MB

Release files / devise_greenness-1.0.3.tar.gz

Download URL devise_greenness-1.0.3.tar.gz
Size 4.7 MB
Tags Source
SHA-256 checksum
How to use checksums
ff8fc62d6858dac1d854284ab58c2eea60af424ba306b3a3ec1e4c21fa2e2a57
BLAKE2b-256 checksum
How to use checksums
114eae8856f54c0b63839c93b6be3df99ef4bf529e9b846006d40789485840ae
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release files / devise_greenness-1.0.3-py3-none-any.whl

Download URL devise_greenness-1.0.3-py3-none-any.whl
Size 13.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2f56c506749067c2e57b7ce816e774af314121ddbaa978e482083e1a82a3032f
BLAKE2b-256 checksum
How to use checksums
4fa1ff3a4b8a1922d52981cd44e1f1a6d4283dcecd4364dcc1cf5814ea3fafb3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Security for devise-greenness 1.0.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.3 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page