Hashwanth Gogineni's other Models Reports

Major Concepts

 

Sign-Up/Login to access Several ML Models and also Deploy & Monetize your own ML solutions for free

Models Home » Domain Usecases » Agriculture » Rice Disease Detection

Rice Disease Detection

Models Status

Model Overview

Rice Disease


Rice is a significant agricultural crop. On the other hand, Crop diseases may drastically lower output and quality, posing a danger to global food supplies. As a result, disease management is crucial for rice production. The key to successful disease management is accurate and quick illness detection, allowing pesticide control measures to be implemented quickly. Manual judgment based on illness appearance is now the most extensively used approach for diagnosing rice crop diseases. However, there are insufficient persons with the necessary expertise in the region to do such activities quickly. As a result, a more efficient and convenient approach for diagnosing rice illness is needed.


Bacterial leaf blight


Xanthomonas oryzae pv. oryzae causes bacterial blight.


It causes seedlings to wilt, as well as the yellowing and drying of leaves.


The illness is particularly prone to spread in regions with weeds and contaminated plant stubbles. 


It may be found in tropical and temperate climates, with the most common irrigated and rainfed lowland regions. 


Temperatures between 25°C to 34°C, with relative humidity exceeding 70%, are ideal for the illness.


'Bacterial blight' is one of the most dangerous diseases that may affect rice crops. 


The earlier the illness strikes, the greater the loss of yield.


When vulnerable types are cultivated in disease-friendly settings, yield loss from bacterial blight can be as high as 70%.


Bacterial blight does not affect yield when plants are infected at the booting stage, resulting in low-quality grains and many damaged kernels.


 


Brown spot


Brown spot, one of the most frequent and destructive rice diseases, has been largely disregarded in the past.


Brown spot is a fungus that affects the coleoptile, leaves, leaf sheaths, panicle branches, glumes, and spikelets of plants.


The most visible harm is many large spots on the leaves that can destroy the entire leaf. 


When a seed becomes infected, it produces empty grains as well as spotted or discoloured seeds.


Brown spot reduces both the quantity and the quality of the product.


In South and Southeast Asia, the disease causes a 5% yield loss on average throughout entire lowland rice cultivation. 


A severely diseased field might lose up to 45 per cent of its production.


Heavily contaminated seeds cause seedling blight, and it kills 1058 per cent of the seedlings. 


It also diminishes the kernel weight and impacts the quality and amount of grains per panicle.


In terms of history, the Brown spot was considered the major factor contributing to the 'Great Bengal Famine' in 1943.


 


Leaf smut


Leaf smut, produced by the fungus Entyloma oryzae, is a widespread but mild rice disease caused by the fungus Entyloma oryzae. 


The fungus creates slightly elevated, angular black dots (sori) on both sides of the leaves. 


It can also cause stains on leaf sheaths. However, this is uncommon. 


The black specks range in length from 0.5 to 5.0 millimetres and in width from 0.5 to 1.5 millimetres. 


Many spots can be discovered on the same leaf, but they are all unique from one another. 


When the epidermis is moist, it splits open and releases the black spores. 


Leaves that have been heavily affected become yellow, and the leaf tips die and turn grey. 


The fungus is dispersed by spores in the air and survives the winter on sick leaf litter in the soil. 


Leaf smut is a late-season ailment that does minimal damage. 


The illness thrives in environments with high nitrogen levels. 


Controlling the situation is not advised.


 


Why Rice Disease Detection?


The project can help agriculture organizations to help detect diseases in rice leaves and take necessary measures to avoid loss of yield.


Dataset


The dataset contains 16,000 images of disease-infected rice leaves. The images are grouped into 4 classes based on the type of disease. There are 4,000 images in each class.


Classes:


1)Bacterial leaf blight


2)Brown spot


3)Healthy


4)Leaf smut



Inception


Inception-v3 is a convolutional neural network design from the Inception family that includes Label Smoothing, Factorized 7 x 7 convolutions, and the inclusion of an auxiliary classifier to transport label information deeper down the network, among other enhancements (along with the use of batch normalization for layers in the sidehead).


An Inception v3 network's architecture is developed one step at a time, as described below:


1. Factorized Convolutions: This decreases the number of parameters in a network, which improves computational efficiency. It also monitors the network's efficiency.


2. Smaller convolutions: substituting smaller convolutions for larger convolutions results in much quicker training. A 5 5 filter, for example, has 25 parameters; two 3 3 filters, in place of a 5 5 convolution, have just 18 (3*3 + 3*3) parameters.


3. Asymmetric convolutions: Instead of a 3 3 convolution, a 1 3 convolution followed by a 3 1 convolution might be used. 


The number of parameters would be significantly greater than the asymmetric convolution described if a 3 3 convolution was substituted with a 2 2 convolution.


4. Auxiliary classifier: an auxiliary classifier is a tiny CNN introduced between layers during training and adds to the main network loss. 


Auxiliary classifiers were utilized for a deeper network in GoogLeNet, whereas an auxiliary classifier works as a regularizer in Inception v3.


5. Grid size reduction: Pooling techniques are commonly used to reduce grid size. 


 

Understanding Code

First, let us import the required libraries for our project.


import os
import numpy as np
import matplotlib.pyplot as plt
from tensorflow.keras.preprocessing import image_dataset_from_directory
import tensorflow as tf
import cv2
from keras.layers import Input, Lambda, Dense, Flatten,GlobalAveragePooling2D, Dropout, Activation
from keras.models import Model
from keras.preprocessing.image import ImageDataGenerator
from keras.models import Sequential
from tensorflow.python.keras.preprocessing.image import ImageDataGenerator
from sklearn.metrics import classification_report, log_loss, accuracy_score


Now, let us load the data into our system.


train_dir = '/content/sample_data/rice-leaf-desease/'

batch_size = 64
train_datagen = ImageDataGenerator(
rescale=1./255,
validation_split=0.20)

train_datagenerator = train_datagen.flow_from_directory(
train_dir,
target_size=(224, 224),
shuffle=True,
batch_size=batch_size,
class_mode='categorical',
color_mode="rgb",
subset='training')

validation_generator = train_datagen.flow_from_directory(
train_dir,
target_size=(224, 224),
batch_size=batch_size,
class_mode='categorical',
color_mode="rgb",
subset='validation',
shuffle = False)

Also, I used the 'flow_from_directory' function to load the images from a directory.
As you can see, I used the "ImageDataGenerator" function for data augmentation purposes.

Next, let us dive into the modelling section of our use case.


from tensorflow.keras.applications import InceptionV3
Incptn = InceptionV3(include_top=False, weights='imagenet', input_shape=(224,224,3))
Incptn.summary()

for layer in Incptn.layers:
layer.trainable=False

So, I chose the 'InceptionV3' model to get accurate predictions.
I used 'imagenet' as weights for our model.


x = Flatten()(Incptn.output)
x = Dense(512,activation='relu')(x)
x = Dense(512,activation='relu')(x)
prediction = Dense(4,activation='softmax')(x)
model = Model(inputs=Incptn.input, outputs=prediction)
model.summary()

I also added a few extra layers to the model for efficient results.

As our model is ready, let us now compile our model.


model.compile(optimizer='adam',loss='categorical_crossentropy',metrics=['accuracy'])

callback = tf.keras.callbacks.EarlyStopping(monitor='accuracy', patience=2)

 


Now let us fit our data into our model.


history = model.fit_generator(train_datagenerator, validation_data=validation_generator, epochs=15, callbacks=callback)


Finally, let us have a look at our model's performance.


 get_acc = history.history['accuracy']
value_acc = history.history['val_accuracy']
get_loss = history.history['loss']
validation_loss = history.history['val_loss']

epochs = range(len(get_acc))
plt.plot(epochs, get_acc, 'r', label='Accuracy of Training data')
plt.plot(epochs, value_acc, 'b', label='Accuracy of Validation data')
plt.title('Training vs validation accuracy')
plt.legend(loc=0)
plt.figure()
plt.show()


# Classification Report

from sklearn.metrics import classification_report

test_labels=validation_generator.classes
predictions=model.predict_generator(validation_generator, verbose=1)
y_pred = np.argmax(predictions, axis=-1)
print(classification_report(test_labels, y_pred))



Here '0' represents 'Bacterial Leaf Blight Disease' and '1' represents 'Brown Spot Disease', '2' represents 'Healthy' and '3' represents 'Leaf Smut Disease' in the classification report.



Thank you for your time.


0 comments