๐ŸŸข v0.2.1 โ€” Production Ready โ€” Live on PyPI

๐Ÿฅญ Mango Disease
AI โ€” Complete Docs

AI-powered Amropali mango disease detection. One command to install, one command to run. Works from any folder, any machine, worldwide.

7
Disease Classes
94.7%
Top Accuracy
5
API Endpoints
0.2.1
Latest Version

โšก 8-Step Quick Start

From zero to fully running API โ€” step by step. Works on Windows, Mac, Linux. No local folder needed.

1
Open PowerShell / Terminal
Easy โ–ผ

Press Windows Key โ†’ type PowerShell โ†’ press Enter.
On Mac/Linux: open Terminal.

โœ… You will see
PS C:\Users\YourName> _
2
Install the Package
~1 min โ–ผ

Copy and paste this command โ†’ press Enter. This installs the AI library + API server tools.

PowerShell
PS> pip install "mango-disease-ai[api]"
โœ… You will see at the end
Successfully installed mango-disease-ai-0.2.1
3
Verify Installation
5 seconds โ–ผ

Check that the package is installed correctly by printing the version number.

PowerShell
PS> python -c "import mango_disease_ai; print(mango_disease_ai.__version__)"
โœ… You will see
0.2.1
4
Start the API Server
First run: 2-3 min โ–ผ

Run this single command from any folder โ€” no need to navigate anywhere. The server starts on port 8000.

PowerShell
PS> mango-api
# Custom port (optional)
PS> mango-api --port 8080
# Alternative (also works)
PS> python -m mango_disease_ai.server
โœ… You will see
============================================================
๐Ÿฅญ Mango Disease AI -- REST API Server v0.2.1
============================================================
Starting on http://0.0.0.0:8000
Welcome page http://localhost:8000
Swagger UI http://localhost:8000/docs
Full Docs http://localhost:8000/guide
Press CTRL+C to stop.
โš ๏ธ First run only: CLIP model (~600 MB) downloads automatically. Wait 2-3 minutes. All future runs start instantly.
5
Open in Browser
Easy โ–ผ

Open Chrome, Edge, or Firefox. Go to these URLs:

๐Ÿ 
๐Ÿ“–
Animated Docs (this page)
http://localhost:8000/guide
๐Ÿงช
Swagger UI โ€” Test API Live
http://localhost:8000/docs
โค๏ธ
6
Test the API via Swagger UI
In Browser โ–ผ

The easiest way to test โ€” no code needed. All in the browser.

b
Click POST /api/analyze to expand it
c
Click "Try it out" button
d
Click "Choose File" โ†’ pick your mango image โ†’ set include_gradcam = false
e
Click the blue "Execute" button โ†’ see the JSON result below
โœ… Example response
{"is_mango": true, "predicted_class": "Healthy", "confidence": 0.9470}
7
Use in Python Code (Optional)
Developers โ–ผ

Use the library directly in your own Python scripts โ€” no server needed.

my_script.py
from mango_disease_ai import analyze, generate_pdf
# Analyze any mango image
result = analyze("your_mango.jpg")
if result["is_mango"]:
  print("Disease :", result["predicted_class"])
  print("Confidence:", f"{result['confidence']:.1%}")
# Generate PDF report
pdf = generate_pdf(result, user_name="Dr. Rahman")
open("report.pdf", "wb").write(pdf)
# Disease : Healthy
# Confidence: 94.7%
8
Stop the Server / Upgrade Later
Easy โ–ผ

Stop the server and keep your package updated.

PowerShell
# Stop the server
Press CTRL + C (in the terminal where mango-api is running)
# Upgrade to latest version later
PS> pip install --upgrade "mango-disease-ai[api]"
# Check version anytime
PS> python -c "import mango_disease_ai; print(mango_disease_ai.__version__)"
# See all options
PS> mango-api --help

Install Options

Choose what you need โ€” library only, or library + API server.

Recommended โ€” Full Install
# Library + API server + mango-api command
PS> pip install "mango-disease-ai[api]"
# Library only (no server)
PS> pip install mango-disease-ai
# Anaconda users (Windows)
PS> & "E:\Anaconda\python.exe" -m pip install "mango-disease-ai[api]"
๐Ÿ“ฆ What gets installed with [api]
mango-disease-ai fastapi uvicorn[standard] python-multipart
Plus: torch, CLIP, timm, Pillow, opencv, fpdf2, transformers (all auto-installed)
๐Ÿ
Python Devs
pip install
mango-disease-ai
๐ŸŒ
API Devs
pip install
"...[api]"
๐Ÿ“ฑ
Any Language
HTTP POST to
localhost:8000

PyPI Library โ€” Python Usage

Basic
Full Output
PDF Report
Fast Mode
basic.py
from mango_disease_ai import analyze
result = analyze("mango.jpg")
if result["is_mango"]:
  print(result["predicted_class"])
  print(result["confidence"])
else:
  print("Not a mango!")
๐Ÿ“ค Output
Healthy
0.9470
full_output.py
from mango_disease_ai import analyze
result = analyze("mango.jpg")
if result["is_mango"]:
  for s in result["all_scores"]:
    print(s['class'], f"{s['score']:.1%}")
  info = result["disease_info"]
  print(info["scientific_name"])
  print(info["symptoms"])
  print(info["remedies"])
pdf_report.py
from mango_disease_ai import analyze, generate_pdf
result = analyze("mango.jpg")
if result["is_mango"]:
  pdf = generate_pdf(result, user_name="Dr. Rahman")
  open("report.pdf", "wb").write(pdf)
  print("Saved: report.pdf")
fast_mode.py
# Fast mode โ€” skip heatmap (~2s vs ~8s)
from mango_disease_ai import analyze
result = analyze("mango.jpg", include_gradcam=False)
print(result["predicted_class"]) # works
print(result["gradcam_base64"]) # None

REST API โ€” HTTP Endpoints

Use from Python, JavaScript, Java, Swift, PHP โ€” any language that sends HTTP.

๐ŸŒ Browser
๐Ÿ Python
โšก JavaScript
๐Ÿ”ง curl
Start Server โ€” Any Folder
# Start from ANYWHERE โ€” no cd needed!
PS> mango-api
# Then open browser:
http://localhost:8000/docs โ† Swagger UI (test everything)
http://localhost:8000/guide โ† This documentation
http://localhost:8000 โ† Welcome page
requests_demo.py
import requests
# Health check
r = requests.get("http://localhost:8000/api/health")
print(r.json()) # {"status":"ok","version":"0.2.1"}
# Analyze image
with open("mango.jpg", "rb") as f:
  r = requests.post("http://localhost:8000/api/analyze",
    files={"image": f}, data={"include_gradcam": "false"})
result = r.json()
print(result["predicted_class"], result["confidence"])
# Download PDF
with open("mango.jpg", "rb") as f:
  r = requests.post("http://localhost:8000/api/report",
    files={"image": f}, data={"user_name": "Dr. Rahman"})
open("report.pdf", "wb").write(r.content)
app.js
async function analyzeMango(imageFile) {
  const formData = new FormData();
  formData.append("image", imageFile);
  formData.append("include_gradcam", "false");
  const res = await fetch("http://localhost:8000/api/analyze",
    { method: "POST", body: formData });
  if (res.status === 422) { alert("Not a mango!"); return; }
  const result = await res.json();
  console.log(result.predicted_class, result.confidence);
  document.getElementById("heatmap").src =
    "data:image/png;base64," + result.gradcam_base64;
}
Terminal / cmd
# Health check
$ curl http://localhost:8000/api/health
# Analyze image
$ curl -X POST http://localhost:8000/api/analyze \
  -F "image=@mango.jpg" -F "include_gradcam=false"
# Download PDF
$ curl -X POST http://localhost:8000/api/report \
  -F "image=@mango.jpg" -F "user_name=Dr. Rahman" \
  --output report.pdf

5 API Endpoints

GET/api/health~10ms
Server alive check. Returns OK + version.
{"status": "ok", "version": "0.2.1"}
GET/api/diseases~5ms
All 7 disease classes with scientific name, symptoms, remedies.
POST/api/analyze~2-8 sec
Upload mango image โ†’ full diagnosis JSON. Returns HTTP 422 if not a mango.
{"is_mango": true, "predicted_class": "Healthy", "confidence": 0.9470,
 "all_scores": [{...}, ...], "disease_info": {...}, "gradcam_base64": "..."}
POST/api/report~10-15 sec
Upload image + name โ†’ download PDF report. Body: image + user_name.
GET/guideThis Page
This animated documentation page โ€” bundled inside the package.

Predicted Output Types

โœ… HEALTHY LEAF
Healthy
Mangifera indica (Normal)
Confidence94.7%
โœ“ No treatment needed
๐Ÿ”ด DISEASED LEAF
Anthracnose
Colletotrichum gloeosporioides
Confidence93.1%
โ†’ Apply copper fungicide
โš ๏ธ NOT A MANGO
Rejected
HTTP 422 Error Response
Mango confidence13.4%
โ†’ Upload a mango image

All 7 Disease Classes

System Architecture

๐Ÿ“ธ Input: Image (JPG/PNG/WebP/BMP)
Any mango leaf or fruit photo
โ†“
๐Ÿ” CLIP Validation
"Is this a mango?"
โŒ Not mango
โ†’ HTTP 422
โ†“ โœ… Is mango
๐Ÿง  AA-ENet Classification
EfficientNet-B0 + CBAM + Transformer
โ†“
๐Ÿ“Š Scores
7 class probabilities
๐ŸŒก๏ธ Grad-CAM++
Heatmap visualization
โ†“
โœ… JSON Result / PDF Report
๐Ÿง  AA-ENet Model
Custom EfficientNet-B0 + CBAM + Transformer. Trained on Amropali mango dataset.
EfficientNet-B0CBAMTransformer
๐Ÿ” CLIP Validation
OpenAI CLIP (ViT-B/32) confirms the image is a mango before running diagnosis.
CLIP ViT-B/32Zero-shot
๐Ÿ“ฆ Package Info v0.2.1
Self-contained: AI model, server, docs all bundled. Works from any folder.
PyPImango-apifpdf2

๐Ÿ“‹ Cheat Sheet

Quick Reference โ€” Every Command
# โ”€โ”€ INSTALL โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
PS> pip install "mango-disease-ai[api]"
PS> pip install --upgrade "mango-disease-ai[api]"
# โ”€โ”€ VERIFY โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
PS> python -c "import mango_disease_ai; print(mango_disease_ai.__version__)"
# โ”€โ”€ START SERVER (from ANY folder) โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
PS> mango-api
PS> mango-api --port 8080
PS> mango-api --help
PS> python -m mango_disease_ai.server
# โ”€โ”€ OPEN IN BROWSER โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
PS> start http://localhost:8000 โ† Welcome page
PS> start http://localhost:8000/guide โ† Full animated docs
PS> start http://localhost:8000/docs โ† Swagger UI testing
# โ”€โ”€ STOP SERVER โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
CTRL + C (in the terminal where mango-api is running)