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.0

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.0
File Size Uploaded Provenance Actions
mango_disease_ai-0.2.0.tar.gz 17.5 MB Without provenance Details for mango_disease_ai-0.2.0.tar.gz

Built distribution (wheel)

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

Total release size: 34.9 MB

Release files / mango_disease_ai-0.2.0.tar.gz

Download URL mango_disease_ai-0.2.0.tar.gz
Size 17.5 MB
Tags Source
SHA-256 checksum
How to use checksums
62064ac6869005ac275ebcc36c5b081ef90590daad2929544d26d6dfab85f884
BLAKE2b-256 checksum
How to use checksums
f329ba5d31143f0616595974c576afab88f45176b7ab865ea7582553254d7546
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.0-py3-none-any.whl

Download URL mango_disease_ai-0.2.0-py3-none-any.whl
Size 17.4 MB
Tags Python 3
SHA-256 checksum
How to use checksums
2212529e97edfe832c34b882410a349ae0d8a9afc1bdcab44f2b6a296c0a8dda
BLAKE2b-256 checksum
How to use checksums
7e008a2449f3172be12f26b0624a86c16e2ebb9e59b279e454ee5c33a5dc9d08
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.0

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