Skip to main content

Rice Leaf Disease Classification

The goal of this project is to create a classifier that can accurately identify different diseases affecting rice leaves. The dataset used for training is sourced from Kaggle and contains multiple classes of rice leaf diseases.

Visit github
  • Preprocessing
  • Model Selection
  • Training Loop
  • Prediction and Visualization
The Slice web application showing a selected user annotation.

Preporcessing

  • Import all needable libraries: torch, matplotlib, pandas and etc.
  • The dataset is split into training (80%), validation (10%), and test sets (10%) using random_split.
  • Data loaders are then created for each subset, with a batch size of 14 for training and validation, and 1 for testing.
  • Multiple user annotations on a shared layer.

    Model Selection

  • The ResNet18 model is loaded using timm, with timm.create_model().
  • The model is initialized with pretrained weights, and the number of output classes is set to 8 (indicating there are 8 types of leaf conditions).
  • The new My Slides tab in slice, showing annotated and favorited slides.

    Loss Function and Optimizer

  • The loss function used is CrossEntropyLoss, appropriate for multi-class classification.
  • The optimizer is Adam, with a learning rate of 3e-4.
  • Training Loop

  • The training loop runs for 10 epochs.
  • Each epoch involves both training and validation phases.
  • The model parameters are updated using backpropagation during training.
  • Validation is performed without gradient tracking, and the validation loss and accuracy are recorded.
  • Students at the University of New South Wales using the new collaborative annotation features

    Prediction and Visualization

  • The code iterates through a batch of images and predicts their classes.
  • Predictions are compared to actual labels.
  • The result and prediction for random samples are visualized using matplotlib.
  • Training and validation accuracy scores are plotted.
  • Students at the University of New South Wales using the new collaborative annotation features