Skip to main content

A Python library for predicting plant diseases from leaf images using trained deep learning models.

Project description

# 🌿 PlantDoc Predictor

🌿 PlantDoc-Predictor

PyPI version License: MIT Python Versions Downloads


A Python library for predicting plant diseases from leaf images using pre-trained or custom deep learning models.


🚀 Features

  • Pretrained models included — Ready-to-use architectures like InceptionV3, ResNet50, and MobileNetV2, trained on the 38-class PlantVillage dataset.
  • 🧠 Unified API — One interface for both built-in and custom .h5 models.
  • 🧩 Custom model support — Load your own model and label mapping JSON.
  • 🌱 Extensible — Easily add new crops, datasets, or models via model_registry.json.
  • 🧰 Visualization support — Displays prediction confidence and leaf images.
  • ⚙️ Cross-platform — Works seamlessly on Windows, macOS, and Linux.

🧠 Why Use PlantDoc-Predictor

PlantDoc-Predictor was created to reduce repetitive work in plant-disease research.
Researchers and agritech developers often train from scratch — this tool eliminates that friction by providing:

  • Pretrained baselines for benchmarking new models.
  • Standardized label sets and metadata for reproducibility.
  • Plug-and-play inference for agricultural image datasets.
  • A unified interface for rapid experimentation and deployment.

Whether you’re a researcher, startup, or precision-agriculture developer, PlantDoc-Predictor simplifies your workflow and lets you focus on innovation — not setup.


📦 Installation

Install directly via pip:

pip install plantdoc-predictor

## 🧩 Quick Start

```python
from plantdoc_predictor import Predictor, list_available_models

# List built-in models
list_available_models()

# Load predictor using InceptionV3
predictor = Predictor(model_name="inceptionv3", verbose=True)

# Predict a sample image
result = predictor.predict("path/to/leaf_image.jpg")
print(result)

🔄 Loading InceptionV3 model...
✅ Model loaded successfully!

================= Prediction Result =================
📂 Image Path     : path/to/leaf_image.jpg
✅ Predicted Class: Apple___Apple_scab
🔢 Confidence     : 98.42%
🏆 Top-3 Predictions:
    Apple___Apple_scab                         98.42%
    Apple___Black_rot                          0.97%
    Apple___Cedar_apple_rust                   0.43%
=====================================================

{'model': 'inceptionv3', 'label': 'Apple___Apple_scab', 'confidence': 0.9842}

Using a Custom Model

You can use your own trained TensorFlow/Keras model instead of the built-in ones.
predictor = Predictor(
    model_path="models/my_custom_model.h5",
    label_path="models/my_labels.json",
    verbose=True
)

result = predictor.predict("path/to/custom_leaf.jpg", show_plot=True)
print(result)

✅ The library automatically detects input shape and normalizes image data. ✅ You can store your label mapping in a JSON file with the format:

{
  "labels": [
    "Apple___Apple_scab",
    "Apple___Black_rot",
    "Apple___Cedar_apple_rust",
    "Apple___healthy"
  ]
}

🧬 Supported Models

Model Name Dataset Input Size Accuracy Description
InceptionV3 PlantVillage 299×299 92.8% High-accuracy model fine-tuned for general plant disease classification.
ResNet50 PlantVillage 224×224 90.3% Residual CNN architecture with deep feature extraction.
MobileNetV2 PlantVillage 224×224 89.4% Lightweight model optimized for mobile and edge deployment.
EfficientNetB0 PlantVillage 224×224 91.1% Modern CNN architecture balancing accuracy and efficiency.

🧩 You can easily extend the library by adding new entries to model_registry.json:

{
  "models": [
    {
      "name": "my_custom_model",
      "path": "models/my_custom_model.h5",
      "labels": "models/my_labels.json",
      "input_size": [224, 224],
      "accuracy": 0.93,
      "description": "Custom fine-tuned model for tomato leaf disease detection"
    }
  ]
}

📝 License

This project is licensed under the MIT License.

You are free to:

  • ✅ Use the library for both commercial and academic purposes
  • 🔧 Modify, distribute, or integrate it into your own software
  • 🌍 Reference and extend it in research or production projects

Just ensure you include the original copyright notice and this license file.

See the full text in the LICENSE file.


🌍 Contributing

Contributions are warmly welcomed! 🌱

We value community participation to make PlantDoc-Predictor more robust, accurate, and user-friendly.

You can contribute by:

  • 🧠 Adding new pretrained or fine-tuned models
  • ⚙️ Improving preprocessing or postprocessing modules
  • 🧩 Extending model registry or dataset support
  • 🧪 Writing new test cases for reproducibility
  • 🐛 Fixing bugs and optimizing performance
  • 📚 Improving documentation and adding usage examples

🔧 Steps to Contribute

  1. Fork this repository
  2. Create your feature branch
    git checkout -b feature/your-feature
    

📫 Contact

Author: Subham Divakar
Email: subhamdivakar@gmail.com
GitHub: shubham10divakar
PyPI: https://pypi.org/project/plantdoc-predictor/
LinkedIn: linkedin.com/in/subhamdivakar
Project Website: My Site

If you have any questions, collaboration ideas, or model suggestions — feel free to reach out!
You can also open an issue or submit a pull request in the GitHub repository.


❤️ Acknowledgements

A heartfelt thank you to all the open-source contributors and researchers who made this project possible:

  • 🌿 PlantVillage Dataset — for providing an invaluable resource for agricultural disease detection.
  • 🤖 TensorFlow/Keras — for powering deep learning model training and inference.
  • 🧩 Python Open Source Community — for libraries that make AI tools easier to build.
  • 🧪 Researchers & Reviewers — for advancing the field of AI in agriculture.
  • 💻 Contributors — for helping test, improve, and document PlantDoc-Predictor.

Your support continues to make plant disease prediction accessible and impactful across the world.


“Empowering agriculture with AI — one leaf at a time.” 🌾
Subham Divakar, Creator of PlantDoc-Predictor

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

plantdoc_predictor-0.1.1.tar.gz (85.9 MB view details)

Uploaded Source

Built Distribution

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

plantdoc_predictor-0.1.1-py3-none-any.whl (85.9 MB view details)

Uploaded Python 3

File details

Details for the file plantdoc_predictor-0.1.1.tar.gz.

File metadata

  • Download URL: plantdoc_predictor-0.1.1.tar.gz
  • Upload date:
  • Size: 85.9 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.10.1

File hashes

Hashes for plantdoc_predictor-0.1.1.tar.gz
Algorithm Hash digest
SHA256 b372203a57f4e171edc8bbb49a0d5c4442c9188db111b9075704f74b2fe97f80
MD5 4e0db74d89a23ea5e8b670501a8caaae
BLAKE2b-256 9be706ac1e049b80540dd869a64b5e0c7bf9ecc1f7af25a67d9af2f8e92bcea7

See more details on using hashes here.

File details

Details for the file plantdoc_predictor-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for plantdoc_predictor-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 103ab57829547e6c2084945d90acb4ac056ff7548dc8e400c7662ebc838e1aa1
MD5 9b388cb39a5fcae3c5d22df64c8a5ea0
BLAKE2b-256 030639d9703f8cf7f612dd0d278ea0141412a2ef82cb1675a3aaac6b880f8be5

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