Skip to main content

Automated Phenological Analysis Package for PhenoCam Data

Project description

PhenoAI: A deep learning Python framework to process close-range time-lapse PhenoCam data

PhenoAI Logo Python License Platform

Advanced Deep Learning Framework for Automated Phenological Analysis of Close-Range Time-Lapse PhenoCam Data

PhenoAI Graphical Abstract

๐ŸŒฟ Overview

PhenoAI is a deep learning framework designed to automate the processing chain of phenological analysis of vegetation from close-range time-lapse PhenoCam data. This framework implements several techniques to provide comprehensive vegetation monitoring, segmentation, and temporal analysis capabilities.

Research Publication: This work is part of the research paper:
"PhenoAI: A deep learning Python framework to process close-range time-lapse PhenoCam data"
by Akash Kumar, Siddhartha Khare, and Sergio Rossi
Published in Ecological Informatics, 2025

๐ŸŽฏ Key Features

  • ๐Ÿ”ฌ Advanced Image Quality Control: Automated detection and filtering of low-quality images
  • ๐ŸŒฑ Vegetation Segmentation: Deep learning-powered vegetation extraction using semantic segmentation
  • ๐Ÿ“Š ROI Analysis: K-means clustering-based Region of Interest (ROI) generation and analysis
  • ๐Ÿ“ˆ Vegetation Indices: Comprehensive calculation of multiple vegetation indices (GCC, BCC, VCI, etc.)
  • ๐Ÿ–ฅ๏ธ Professional GUI: Advanced parameter tuning interface with real-time preview
  • โšก Batch Processing: Efficient processing of large-scale time-lapse datasets
  • ๐Ÿ“‹ Interactive CLI: User-friendly command-line interface with guided workflows

๐Ÿš€ Quick Start

Installation

# Install from PyPI (recommended)
pip install phenoai-package

# Or install with TensorFlow support
pip install phenoai-package[tensorflow]

# Or install all optional dependencies
pip install phenoai-package[all]

๐Ÿ“ฆ Model File Download: Due to PyPI size limitations, the pre-trained model (355MB) is not included in the package. Download it separately:

  • GitHub Release: Download Basic_Vegetation_Model.h5 from the latest release
  • Direct Download: Available in the GitHub repository under /Model/ directory
  • Alternative: The framework will prompt you to download the model on first use

Alternative Installation Methods

# From GitHub releases (if PyPI is not available)
pip install https://github.com/kharesiddhartha/phenoAI/releases/download/v1.2.0/phenoai-1.2.0-py3-none-any.whl

# For development
git clone https://github.com/kharesiddhartha/phenoAI.git
cd phenoAI
pip install -e .

Basic Usage

# Launch interactive mode (recommended for beginners)
python -m phenoAI.cli --interactive

# Or if installed globally
phenoai --interactive

# Direct usage with parameters
python -m phenoAI.cli --input ./images --output ./results

๐Ÿ“‹ Detailed Usage Guide

1. Interactive Command Line Interface

The easiest way to get started is using the interactive CLI:

python -m phenoAI.cli --interactive

This will present you with a menu-driven interface:

๐ŸŒฟ PhenoAI v1.2.0 - Phenological Analysis Framework
๐Ÿ“š Advanced Deep Learning for Close-Range PhenoCam Data Analysis

Select workflow:
1. ๐Ÿ” Image Quality Control
2. ๐ŸŒฑ Vegetation Segmentation  
3. ๐Ÿ“Š ROI Generation and Analysis
4. ๐Ÿ“ˆ Vegetation Index Calculation
5. ๐ŸŽฏ Complete Workflow (All Steps)
6. ๐Ÿ–ฅ๏ธ Parameter Tuning GUI
7. โŒ Exit

Enter your choice (1-7):

2. Step-by-Step Workflow

Step 1: Image Quality Control

from phenoAI import PhenoAI

# Initialize framework
analyzer = PhenoAI()

# Set input directory containing your time-lapse images
analyzer.input_dir = "path/to/your/images"

# Run quality control
quality_results = analyzer.step1_image_quality_control()

# Results will be saved to:
# - Output/01_processing/high_quality_images/
# - Output/02_low_quality_images/

Features:

  • Automated blur detection using Laplacian variance
  • Brightness and contrast analysis
  • Noise level assessment
  • Histogram-based quality metrics

Step 2: Vegetation Segmentation

# Run vegetation segmentation on quality-filtered images
segmentation_results = analyzer.step2_vegetation_segmentation()

# Results include:
# - Vegetation masks (binary)
# - Vegetation extraction (RGB)
# - Segmentation metrics and confidence scores

Deep Learning Model:

  • Uses advanced semantic segmentation (DeepLabV3+ architecture)
  • Pre-trained on diverse vegetation datasets
  • Supports multiple vegetation types (grass, crops, trees, etc.)
  • Confidence-based result filtering

Step 3: ROI Generation and Analysis

# Generate ROIs using K-means clustering on vegetation areas
roi_results = analyzer.step3_roi_generation()

# Interactive ROI preview with professional GUI
analyzer.display_roi_preview_popup(segmentation_results)

# Select specific ROIs for analysis
analyzer.selected_rois = [0, 2, 4, 6]  # or use 'all'

ROI Features:

  • K-means clustering on vegetation pixels
  • Polygon-based ROI boundaries
  • Interactive preview with colorful cluster visualization
  • Customizable ROI selection

Step 4: Vegetation Index Calculation

# Calculate comprehensive vegetation indices
vi_results = analyzer.step4_vegetation_indices()

# Available indices:
# - GCC (Green Chromatic Coordinate)
# - BCC (Blue Chromatic Coordinate)
# - RCC (Red Chromatic Coordinate)
# - ExG (Excess Green)
# - VCI (Vegetation Contrast Index)

3. Advanced Parameter Tuning

Launch the professional GUI for parameter optimization:

from phenoAI.gui import run_parameter_tuning

# Launch parameter tuning interface
run_parameter_tuning()

GUI Features:

  • Real-time parameter adjustment with live preview
  • 5 sample images per filter type
  • Instant detection status feedback
  • Professional Tkinter interface
  • Save/load parameter configurations

4. Batch Processing

# Process multiple directories
import os
from phenoAI import PhenoAI

directories = [
    "dataset1/time_series_1/",
    "dataset1/time_series_2/",
    "dataset2/wheat_2024/"
]

for directory in directories:
    analyzer = PhenoAI()
    analyzer.input_dir = directory
    analyzer.output_dir = f"results/{os.path.basename(directory)}"
    
    # Run complete workflow
    analyzer.run_full_workflow()

๐Ÿ› ๏ธ Advanced Configuration

Custom Model Integration

# Use custom segmentation model
analyzer = PhenoAI()
analyzer.segmentation_model_path = "path/to/your/custom_model.h5"

# Set custom vegetation labels
analyzer.selected_vegetation_label = "crop"  # or "grass", "tree", etc.

ROI Configuration

# Customize ROI generation parameters
roi_params = {
    "n_clusters": 8,        # Number of K-means clusters
    "min_roi_size": 100,    # Minimum ROI size in pixels
    "max_roi_size": 5000,   # Maximum ROI size in pixels
    "roi_shape": "polygon"  # ROI shape type
}

analyzer.set_roi_parameters(roi_params)

Quality Control Thresholds

# Adjust quality control parameters
quality_params = {
    "blur_threshold": 100.0,      # Laplacian variance threshold
    "brightness_min": 50,         # Minimum brightness
    "brightness_max": 200,        # Maximum brightness
    "contrast_threshold": 30      # Minimum contrast
}

analyzer.set_quality_parameters(quality_params)

๐Ÿ“Š Output Structure

PhenoAI generates a comprehensive output directory structure:

Output/
โ”œโ”€โ”€ 01_processing/
โ”‚   โ”œโ”€โ”€ high_quality_images/     # Quality-filtered images
โ”‚   โ””โ”€โ”€ processing_log.json      # Processing metadata
โ”œโ”€โ”€ 02_low_quality_images/       # Rejected images with reasons
โ”œโ”€โ”€ 03_segmentation_outputs/     # Vegetation masks and extractions
โ”‚   โ”œโ”€โ”€ masks/                   # Binary vegetation masks
โ”‚   โ”œโ”€โ”€ extractions/             # RGB vegetation extractions
โ”‚   โ””โ”€โ”€ metrics/                 # Segmentation confidence scores
โ”œโ”€โ”€ 04_roi_analysis/             # ROI results and visualizations
โ”‚   โ”œโ”€โ”€ roi_boundaries/          # ROI polygon coordinates
โ”‚   โ”œโ”€โ”€ roi_previews/           # Visual ROI overlays
โ”‚   โ””โ”€โ”€ cluster_analysis/        # K-means clustering results
โ”œโ”€โ”€ 05_vegetation_indices/       # Calculated indices
โ”‚   โ”œโ”€โ”€ gcc_results/           # GCC time series
โ”‚   โ”œโ”€โ”€ exg_results/            # ExG time series
โ”‚   โ””โ”€โ”€ comprehensive_indices/   # All indices combined
โ””โ”€โ”€ reports/
    โ”œโ”€โ”€ summary_report.html      # Comprehensive analysis report
    โ”œโ”€โ”€ quality_metrics.csv      # Quality control statistics
    โ”œโ”€โ”€ segmentation_metrics.csv # Segmentation performance
    โ””โ”€โ”€ temporal_analysis.csv    # Time-series vegetation indices

๐Ÿงช Example Workflows

Workflow 1: Basic Vegetation Monitoring

from phenoAI import PhenoAI

# Initialize analyzer
analyzer = PhenoAI()
analyzer.input_dir = "wheat_field_2024/"

# Run complete automated workflow
results = analyzer.run_full_workflow()

# Access results
print(f"Processed {len(results['high_quality_images'])} images")
print(f"Generated {len(results['rois'])} ROIs")
print(f"GCC temporal trend: {results['vegetation_indices']['gcc_trend']}")

Workflow 2: Custom ROI Analysis

# Step-by-step processing with custom ROI selection
analyzer = PhenoAI()
analyzer.input_dir = "crop_monitoring/"

# Quality control
quality_results = analyzer.step1_image_quality_control()

# Vegetation segmentation
seg_results = analyzer.step2_vegetation_segmentation(quality_results)

# Generate and preview ROIs
analyzer.step3_roi_generation(seg_results)
analyzer.display_roi_preview_popup(seg_results)

# Manual ROI selection
analyzer.selected_rois = [1, 3, 5, 7, 9]  # Select specific ROIs

# Calculate indices for selected ROIs only
vi_results = analyzer.step4_vegetation_indices(roi_subset=analyzer.selected_rois)

Workflow 3: Parameter Optimization

# Launch GUI for parameter tuning
from phenoAI.gui import run_parameter_tuning

# Interactive parameter optimization
run_parameter_tuning()

# Apply optimized parameters
analyzer = PhenoAI()
analyzer.load_parameters("optimized_params.json")
analyzer.run_full_workflow()

๐Ÿ”ง Troubleshooting

Common Issues and Solutions

1. Model Loading Issues

# If segmentation model fails to load
analyzer = PhenoAI()
analyzer.download_pretrained_model()  # Download latest model
analyzer.segmentation_model_path = "Model/Basic_Vegetation_Model.h5"

2. Memory Issues with Large Datasets

# Process in smaller batches
analyzer.set_batch_size(32)  # Reduce batch size
analyzer.enable_memory_optimization(True)

3. GUI Issues

# If GUI fails to launch
import tkinter as tk
try:
    root = tk.Tk()
    root.destroy()
    print("โœ… Tkinter available")
except:
    print("โŒ Tkinter not available - install tkinter package")

Performance Optimization

# Enable GPU acceleration (if available)
analyzer.enable_gpu(True)

# Parallel processing
analyzer.set_num_workers(4)  # Adjust based on CPU cores

# Memory-efficient processing
analyzer.enable_lazy_loading(True)

๐Ÿ“š API Reference

Core Classes

PhenoAI

Main analysis framework class.

Methods:

  • step1_image_quality_control() - Image quality filtering
  • step2_vegetation_segmentation() - Deep learning segmentation
  • step3_roi_generation() - ROI clustering and generation
  • step4_vegetation_indices() - Vegetation index calculation
  • run_full_workflow() - Complete automated processing

ParameterTuningGUI

Advanced parameter optimization interface.

Features:

  • Real-time parameter adjustment
  • Multi-image preview
  • Parameter persistence
  • Export/import configurations

Utility Functions

from phenoAI.utils import (
    calculate_vegetation_index,
    apply_quality_filters,
    generate_roi_polygons,
    create_temporal_plots
)

# Calculate custom vegetation index
custom_vi = calculate_vegetation_index(
    image_path="sample.jpg",
    index_type="GCC",
    roi_coordinates=[(100, 100), (200, 200)]
)

๐Ÿค Contributing

We welcome contributions to PhenoAI! Please follow these guidelines:

  1. Fork the repository and create a feature branch
  2. Follow PEP 8 coding standards
  3. Add comprehensive tests for new features
  4. Update documentation for API changes
  5. Submit a pull request with detailed description

Development Setup

# Clone for development
git clone https://github.com/your-username/phenoAI.git
cd phenoAI

# Create virtual environment
python -m venv phenoai_dev
source phenoai_dev/bin/activate  # On Windows: phenoai_dev\Scripts\activate

# Install in development mode
pip install -e .[dev]

# Run tests
python -m pytest tests/

๐Ÿ“„ Citation

If you use PhenoAI in your research, please cite our paper:

Kumar, A., Khare, S., & Rossi, S. (2025). PhenoAI: A deep learning Python framework to process close-range time-lapse PhenoCam data. Ecological Informatics, 88, 103134. https://doi.org/10.1016/j.ecoinf.2025.103134

```bibtex
@article{KUMAR2025103134,
title = {PhenoAI: A deep learning Python framework to process close-range time-lapse PhenoCam data},
journal = {Ecological Informatics},
volume = {88},
pages = {103134},
year = {2025},
issn = {1574-9541},
doi = {https://doi.org/10.1016/j.ecoinf.2025.103134},
url = {https://www.sciencedirect.com/science/article/pii/S1574954125001438},
author = {Akash Kumar and Siddhartha Khare and Sergio Rossi},
keywords = {Close-range Remote Sensing, GCC, Forest Phenology, PhenoCam, Python, Deep Learning}
}

๐Ÿ“ž Support & Contact

๐Ÿ“‹ License

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

๐Ÿ™ Acknowledgments

  • Deep learning models based on DeepLabV3+ architecture
  • Vegetation index calculations following established remote sensing protocols
  • GUI framework built with Python Tkinter
  • Segmentation pipeline inspired by computer vision best practices

PhenoAI v1.2.0 - Advancing Phenological Research with Deep Learning

Developed by Akash Kumar, Siddhartha Khare and Sergio Rossi | Published in Ecological Informatics 2025

GitHub stars GitHub forks

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

phenoai_package-1.2.1.post1.tar.gz (2.6 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

phenoai_package-1.2.1.post1-py3-none-any.whl (99.7 kB view details)

Uploaded Python 3

File details

Details for the file phenoai_package-1.2.1.post1.tar.gz.

File metadata

  • Download URL: phenoai_package-1.2.1.post1.tar.gz
  • Upload date:
  • Size: 2.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for phenoai_package-1.2.1.post1.tar.gz
Algorithm Hash digest
SHA256 f6cf24ba4615e96d9194d63ea10d31d803b5fa27af9458fc1b2ce5122a1df2fd
MD5 c3f2524178a26fd3bb98077ef8d2b48c
BLAKE2b-256 a9381d3e2ea9bcb2539096c7e5fb0494fee80b4ec1ef81cacf42c5c569749770

See more details on using hashes here.

File details

Details for the file phenoai_package-1.2.1.post1-py3-none-any.whl.

File metadata

File hashes

Hashes for phenoai_package-1.2.1.post1-py3-none-any.whl
Algorithm Hash digest
SHA256 96a2c3ac98854b130c122849c00c1748ab680b3cc7a16626871800e5831bd492
MD5 06c9c67bf0c7a77d09e6e30ddb846321
BLAKE2b-256 89d19aae3099a0b8dda379132984bfb5c7718ac2ebd08b952700e0f677994771

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page