Metadata-Version: 2.4
Name: cassava-classifier
Version: 0.0.4
Summary: Cassava leaf disease classification using Deep neural network in Pytorch
Author: Prasanna Kumar, PS Vishnu
License-Expression: MIT
Project-URL: Homepage, https://github.com/p-s-vishnu/cassava-leaf-disease-classification
Keywords: image classification,leaf disease classifier,pytorch
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: albumentations>=0.5.2
Requires-Dist: opencv-python>=4.5.1
Requires-Dist: pandas>=1.2.3
Requires-Dist: scikit-learn>=0.24.1
Requires-Dist: timm>=0.4.5
Requires-Dist: torch>=2.0.0
Requires-Dist: typer[all]>=0.9.0
Provides-Extra: dev
Requires-Dist: ruff; extra == "dev"
Requires-Dist: mypy; extra == "dev"
Requires-Dist: pytest; extra == "dev"
Provides-Extra: apex
Requires-Dist: apex; extra == "apex"
Dynamic: license-file

# Cassava leaf disease classification
[![PyPI version shields.io](https://img.shields.io/badge/pypi-0.0.2-blue)](https://pypi.org/project/cassava-classifier/)  [![Downloads](https://pepy.tech/badge/cassava-classifier)](https://pepy.tech/project/cassava-classifier)


The idea of this project is to build an image classifier to find out healthy and diseased cassava leaves.

There are 4 different classes of leaf diseases namely - `Cassava Bacterial Blight (CBB),Cassava Brown Streak Disease (CBSD),Cassava Green Mottle (CGM) and Cassava Mosaic Disease (CMD)`.


## Web app
[![Open Web App in Streamlit](https://static.streamlit.io/badges/streamlit_badge_black_white.svg)](https://share.streamlit.io/p-s-vishnu/cassava_app/main/web/app.py)
<img src="static/cassava.gif" alt="inference" style="width:80%;" />


## Swagger documentation for API
[![API Link](https://img.shields.io/badge/Launch%20Cassava%20API-Swagger-blue?style=for-the-badge&logo=microsoft%20azure)](http://52.224.254.7:8003/docs)
<img src="static/api.gif" alt="inference" style="width:80%;" />


## Installation

`pip install cassava-classifier`



## Inference example

```python
from PIL import Image
from cassava.pretrained import get_model

image = Image.open("<insert your image path here>")

# Use cassava.list_models() to list of available trained models
model = get_model(name:str)
model.predict_as_json(image: np.array)
>> {"class_name":str, "confidence": np.float}

```
Try out the inference code either on google colab or kaggle.

[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1gPLY6nqF6P4WdvIRIAH_aYQn-iWkzvqs?usp=sharing) [![Kaggle](https://kaggle.com/static/images/open-in-kaggle.svg)](https://www.kaggle.com/vpkprasanna/cassava-inference-from-pypi)

## Development Setup

### Pre-commit hooks

This project uses [pre-commit](https://pre-commit.com/) to run linting, formatting, and type-checking automatically before each commit.

```bash
# Install pre-commit
uv tool install pre-commit

# Install the git hooks
pre-commit install

# (Optional) Run against all files manually
pre-commit run --all-files
```

The hooks include:
- **ruff** — linting with auto-fix + formatting (replaces black, isort, flake8)
- **pre-commit-hooks** — YAML/JSON validation, merge conflict detection, trailing whitespace
- **mypy** — static type checking

## Other details
- Training data can be found on the [Kaggle competition page](https://www.kaggle.com/c/cassava-leaf-disease-classification)

- Streamlit app code can be found [here](https://github.com/p-s-vishnu/cassava_app).

[Github discussion forum](https://github.com/p-s-vishnu/cassava-leaf-disease-classification/discussins)


## Blog

[Medium link]


## Acknowledgements

We would like to thank Kaggle community as a whole for providing an avenue to learn and discuss latest data science/machine learning advancements but a hat tip to whose code was used / who inspired us.

1. Vladimir Iglovikov for his wonderful article ["I trained a model. What is next?"](https://ternaus.blog/tutorial/2020/08/28/Trained-model-what-is-next.html) — [archived copy](docs/iglovikov-trained-model-what-is-next.md)

2. [Y. Nakama](https://www.kaggle.com/yasufuminakama) for the baseline code.
