Skip to main content

mango-disease-ai 🥭

AI-powered Amrapali mango disease detection - reject non-mango photos, classify 7 diseases, mark the affected area with Grad-CAM, and create PDF reports in English or Bangla.

PyPI version Python 3.10+ License: MIT

mango-disease-ai is the engine behind AmropaliNet, a web app that helps Bangladeshi mango farmers detect disease from one photo. It runs the AA-ENet model (EfficientNet-B0 + CBAM + Transformer, trained on 3,500 Amrapali images) and ships the trained weights inside the package.

Feature
🥭 Mango check Rejects photos that are not a mango (CLIP zero-shot + a second model check)
🔍 7 classes Anthracnose, Bacterial Canker, Healthy, Powdery Mildew, Scab, Sooty Mould, Stem End Rot
🔥 Grad-CAM Heatmap of where the model looked
🎯 Affected area Likely affected area outlined on the photo, with its share of the image
📄 PDF report One page, English or Bangla
🌐 REST API mango-api starts a ready-made server with Swagger docs

Install

pip install mango-disease-ai            # Python library
pip install "mango-disease-ai[api]"     # + REST API server (FastAPI)

The first analysis downloads the CLIP mango checker (~600 MB) from Hugging Face once; later runs use the cache.

Python quick start

from mango_disease_ai import analyze, generate_pdf

result = analyze("mango.jpg")          # path, bytes, PIL.Image or file object

if not result["is_mango"]:
    print("Not a mango photo")
else:
    print(result["predicted_class"], f"{result['confidence']:.1%}")   # Anthracnose 95.4%
    print("Affected area:", result["affected_percent"], "%")          # None for Healthy
    for step in result["disease_info"]["remedies"]:
        print("-", step)

    # PDF report in English or Bangla
    open("report_en.pdf", "wb").write(generate_pdf(result, user_name="Arpon", lang="en"))
    open("report_bn.pdf", "wb").write(generate_pdf(result, user_name="আরপন", lang="bn"))

Fast mode (no heatmap): analyze("mango.jpg", include_gradcam=False).

Result fields

Key Meaning
is_mango, mango_confidence Mango check result
predicted_class, confidence Top class and its probability
all_scores All 7 classes, highest first: [{"class": ..., "score": ...}]
disease_info scientific_name, description, symptoms, remedies
original_base64 Photo (JPEG, base64, 448x448)
gradcam_base64 Grad-CAM heatmap overlay (JPEG, base64)
marked_base64 Photo with the likely affected area outlined (JPEG, base64; None for Healthy)
affected_percent Share of the photo inside the outline, % (AI estimate)

REST API

mango-api                 # or: python -m mango_disease_ai.server  (--port 8080)

Open http://localhost:8000/docs to try every endpoint.

Method Path What it does
GET /api/health Server + model status
GET /api/diseases Info for all 7 classes
POST /api/analyze image (+ include_gradcam) -> diagnosis JSON
POST /api/report image, user_name, lang=en|bn -> PDF
curl -F "image=@mango.jpg" http://localhost:8000/api/analyze
curl -F "image=@mango.jpg" -F "user_name=Arpon" -F "lang=bn" http://localhost:8000/api/report -o report_bn.pdf
const form = new FormData();
form.append("image", fileInput.files[0]);
const res = await fetch("http://localhost:8000/api/analyze", { method: "POST", body: form });
const data = await res.json();
if (!res.ok) console.log(data.detail.code);   // e.g. "not_mango"
else console.log(data.predicted_class, data.confidence);

Errors return {"detail": {"code": ..., "message": ...}}: 400 bad_type / too_large / empty / bad_image / no_name / bad_lang · 422 not_mango (+ mango_confidence) · 503 model_missing / mango_check_unavailable / bn_pdf_unavailable · 500 analysis_failed / report_failed.

What's new in 0.2.0

  • Likely affected area outlined on the photo (marked_base64, affected_percent)
  • PDF report in Bangla (lang="bn") as well as English, with a new one-page design
  • Stricter mango check (18 CLIP labels + second model check)
  • Clear error codes, model status in /api/health, models load at server start
  • Sharper 448 px images (JPEG)

Team

AIUB Student Group - Arpon, Oni, Md. Ibtihazzaman · Supervised by Dr. Md. Saef Ullah Miah Contact: arponamit.55@gmail.com · https://github.com/Arpon-30

For guidance only. Always consult a qualified agronomist for crop management decisions.

License: MIT. The bundled Hind Siliguri font is under the SIL Open Font License (mango_disease_ai/fonts/OFL.txt).

Metadata

Release files for mango-disease-ai 0.2.1

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

Source distribution (sdist)

Source distribution for mango-disease-ai 0.2.1
File Size Uploaded Provenance Actions
mango_disease_ai-0.2.1.tar.gz 17.5 MB Without provenance Details for mango_disease_ai-0.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mango-disease-ai 0.2.1
File Interpreter ABI Platform Actions
mango_disease_ai-0.2.1-py3-none-any.whl Python 3 none any Details for mango_disease_ai-0.2.1-py3-none-any.whl

Total release size: 34.9 MB

Release files / mango_disease_ai-0.2.1.tar.gz

Download URL mango_disease_ai-0.2.1.tar.gz
Size 17.5 MB
Tags Source
SHA-256 checksum
How to use checksums
93edc6403cc28c02392a02475c9ae5d9aa06f88c2e5d2eba8e238925488a7069
BLAKE2b-256 checksum
How to use checksums
a397fb7fce99396b0c092d8d92cd7a421d3cde438c276c8f58bc36a7501b96c3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.17

Release files / mango_disease_ai-0.2.1-py3-none-any.whl

Download URL mango_disease_ai-0.2.1-py3-none-any.whl
Size 17.4 MB
Tags Python 3
SHA-256 checksum
How to use checksums
974f047f18eea2d18509ad7130c5efb24b0db3dc23431f6e5c3a8ae1864b7c72
BLAKE2b-256 checksum
How to use checksums
3b92f991ec9ddadac87c073aa1c110f5ea89b2f4d9acc41f827b9fcab6ffd1fb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.17

Security for mango-disease-ai 0.2.1

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.

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