Skip to content

amasuba/BioViT3R-Beta

Repository files navigation

🌱 BioViT3R-Beta: Advanced Plant Analysis Platform

License: MIT Python 3.8+ PyTorch Gradio

BioViT3R-Beta is a comprehensive plant analysis platform that combines cutting-edge computer vision, 3D reconstruction, and AI technologies to provide advanced agricultural insights. The platform integrates VGGT 3D reconstruction, multi-dataset fruit detection, plant health assessment, and IBM Granite AI assistance.

✨ Key Features

🔬 Core Capabilities

  • VGGT 3D Reconstruction: Single-image to 3D point cloud conversion
  • Multi-Dataset Fruit Detection: Trained on ACFR + MinneApple datasets (41,000+ annotations)
  • Plant Health Assessment: Disease and stress detection using computer vision
  • Growth Stage Classification: Automated phenological analysis
  • Biomass Estimation: Volumetric calculations from 3D reconstructions
  • IBM Granite AI Assistant: Agricultural expertise and intelligent insights

🚀 Technologies Used

  • Deep Learning: PyTorch, Transformers, Detectron2
  • 3D Processing: Open3D, Trimesh, Point Cloud Library
  • Computer Vision: OpenCV, Albumentations, Scikit-image
  • Web Interface: Gradio, Streamlit
  • AI Integration: IBM Watsonx.ai, Granite models
  • Data Processing: NumPy, Pandas, SciPy

📋 Table of Contents

🛠️ Installation

Prerequisites

  • Python 3.8 or higher
  • CUDA-compatible GPU (recommended for optimal performance)
  • Git LFS for model files

Option 1: From Source

# Clone the repository
git clone https://github.com/amasuba/BioViT3R-Beta.git
cd BioViT3R-Beta

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

# Install dependencies
pip install -r requirements.txt

# Install package in development mode
pip install -e .

Option 2: Using pip (when published)

pip install biovitr-beta

Option 3: Docker

# Build the Docker image
docker build -t biovitr-beta .

# Run with GPU support
docker run --gpus all -p 7860:7860 biovitr-beta

🚀 Quick Start

Web Interface

Launch the Gradio web interface:

python app.py

Visit http://localhost:7860 in your browser to access the interactive interface.

Command Line Interface

Process a single image:

python main.py single /path/to/plant/image.jpg /path/to/output/

Batch process multiple images:

python main.py batch /path/to/images/ /path/to/output/ --analysis-type complete

Python API

from src.models.vggt_reconstructor import VGGTReconstructor
from src.models.plant_analyzer import PlantAnalyzer

# Initialize models
reconstructor = VGGTReconstructor('models/vggt/')
analyzer = PlantAnalyzer({'health_classification_path': 'models/health_classification/'})

# Load and analyze image
import cv2
image = cv2.imread('path/to/plant/image.jpg')

# 3D reconstruction
point_cloud, mesh = reconstructor.reconstruct_3d(image)

# Health analysis
health_results = analyzer.analyze_health(image)

print(f"Health Score: {health_results['health_score']}")
print(f"Detected Issues: {health_results['detected_issues']}")

📖 Usage

Analysis Types

Complete Analysis

Performs all available analyses including 3D reconstruction, health assessment, fruit detection, and biomass estimation.

# Via CLI
python main.py single image.jpg output/ --analysis-type complete

# Via API
results = app.analyze_plant(image, analysis_type="complete")

3D Reconstruction Only

python main.py single image.jpg output/ --analysis-type 3d

Health Assessment Only

python main.py single image.jpg output/ --analysis-type health

Fruit Detection Only

python main.py single image.jpg output/ --analysis-type fruits

Supported Image Formats

  • JPEG/JPG
  • PNG
  • BMP
  • TIFF
  • WebP

Video Processing

Process video files frame by frame:

from src.utils.video_processor import VideoProcessor

processor = VideoProcessor()
results = processor.process_video('path/to/video.mp4', 'output_dir/')

⚙️ Configuration

Main Configuration (configs/app_config.yaml)

models:
  vggt_model_path: "models/vggt/"
  fruit_detection_path: "models/fruit_detection/"
  health_classification_path: "models/health_classification/"

processing:
  input_size: [224, 224]
  batch_size: 32
  device: "cuda"  # or "cpu"

ibm_watsonx:
  project_id: "your_project_id"
  model_id: "ibm/granite-13b-chat-v2"
  api_endpoint: "https://us-south.ml.cloud.ibm.com"

interface:
  theme: "soft"
  title: "BioViT3R-Beta: Plant Analysis Platform"
  port: 7860

Environment Variables

Create a .env file:

IBM_WATSON_APIKEY=your_api_key_here
IBM_PROJECT_ID=your_project_id_here
IBM_WATSON_URL=https://us-south.ml.cloud.ibm.com
WANDB_API_KEY=your_wandb_key  # Optional: for experiment tracking

📊 Datasets

ACFR Orchard Fruit Dataset

  • Source: Australian Centre for Field Robotics
  • Content: Apple detection in orchard environments
  • Images: 1,000+ labeled images
  • Usage: Fruit detection model training

MinneApple Dataset

  • Source: University of Minnesota
  • Content: 41,000+ apple annotations
  • Images: 670+ high-resolution images
  • Usage: Enhanced fruit detection accuracy

Dataset Setup

Download and prepare datasets:

python scripts/setup_datasets.py --dataset acfr --path data/acfr_orchard/
python scripts/setup_datasets.py --dataset minneapple --path data/minneapple/

🔧 Model Training

Custom Fruit Detection

Train on your own dataset:

python scripts/train_fruit_detector.py \
    --dataset_path /path/to/custom/dataset \
    --config configs/training_config.yaml \
    --output_dir models/custom_fruit_detection/

Health Classification

python scripts/train_health_classifier.py \
    --dataset_path /path/to/health/dataset \
    --epochs 100 \
    --batch_size 32

📈 Performance Benchmarks

Model Component Accuracy Speed (GPU) Speed (CPU)
Fruit Detection 94.2% mAP 45 FPS 8 FPS
Health Classification 91.7% 120 FPS 15 FPS
3D Reconstruction - 12 FPS 2 FPS
Growth Stage 88.5% 150 FPS 20 FPS

🐛 Troubleshooting

Common Issues

CUDA Out of Memory

# Reduce batch size in config
# Or use CPU mode
export CUDA_VISIBLE_DEVICES=""

Model Download Fails

# Manual download
python scripts/download_models.py --model vggt --path models/vggt/

IBM Watsonx Connection Error

  • Verify API credentials in .env file
  • Check network connectivity
  • Ensure project ID is correct

Log Files

Check logs for detailed error information:

  • Application logs: logs/biovitr_app.log
  • CLI logs: logs/biovitr_cli.log
  • Training logs: logs/training/

🤝 Contributing

We welcome contributions to BioViT3R-Beta! Please see our contributing guidelines for details.

Development Setup

# Install development dependencies
pip install -e ".[dev]"

# Install pre-commit hooks
pre-commit install

# Run tests
pytest tests/

# Check code style
black src/ tests/
flake8 src/ tests/

Submitting Changes

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

📚 Documentation

📄 License

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

🙏 Acknowledgments

  • ACFR for the Orchard Fruit Dataset
  • University of Minnesota for the MinneApple Dataset
  • IBM for Watsonx.ai and Granite models
  • PyTorch and Open3D communities
  • All contributors and researchers in agricultural AI

📞 Contact


⭐ If you find BioViT3R-Beta useful, please star the repository and share it with the community!

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages