I have a Mango Farm of over 200 Trees, these are prone to diseases like powdery mildew, anthracnose, die back, blight, red rust, sooty mould, etc. and once it gets affected to one plant it keeps spreading. To avoid this I have created a Machine Learning Model to detect if plant is unhealthy or not using images of leaves . The inference of this model is Optimised by OpenVino and gaining Inference Speed over 72 times than Normal version.
Introduction:The training and inference of model is done on Intel Xeon and Ubuntu 18.04. The dataset is used from here. I have used Tensorflow 2.0 for training and OpenVino 20.4 for Inference. When we add images of leaf for input it outputs probability and flag if leaf has disease or not.
All Project code is also Executed on Google Colab for easy understanding
Benefits:- Farmers can easily find out if their plants are affected or not.
- By using OpenVino the Inference becomes much fast (0.005 Seconds per Image) so it doesn't take much amount of time.
- It can be easily integrated to Embedded Devices using Intel Compute Stick and Drones.
- Due to this it will take less amount of pesticides as we know which plants are infected.
- Due to this project use of pesticides will be reduced.
- Helping Farmers to increase their Harvest and save their time.
- I have used Intel's OpenVino Toolkit on Inference of the trained model.
- OpenVino helps a-lot in increasing speed of inference
OpenVino Timestamps Details: Sep 17, 12:15 AM, aniketdhole991@gmail.com
Algorithm:It is a Classification Problem so I will be using CNN with Convolution and Max Pooling Layers.
Layer (type) Output Shape Param #
=================================================================
conv2d (Conv2D) (None, 180, 180, 16) 448
_________________________________________________________________
max_pooling2d (MaxPooling2D) (None, 90, 90, 16) 0
_________________________________________________________________
conv2d_1 (Conv2D) (None, 90, 90, 32) 4640
_________________________________________________________________
max_pooling2d_1 (MaxPooling2 (None, 45, 45, 32) 0
_________________________________________________________________
conv2d_2 (Conv2D) (None, 45, 45, 64) 18496
_________________________________________________________________
max_pooling2d_2 (MaxPooling2 (None, 22, 22, 64) 0
_________________________________________________________________
dropout (Dropout) (None, 22, 22, 64) 0
_________________________________________________________________
flatten (Flatten) (None, 30976) 0
_________________________________________________________________
dense (Dense) (None, 128) 3965056
_________________________________________________________________
dense_1 (Dense) (None, 2) 258
=================================================================
Total params: 3,988,898
Trainable params: 3,988,898
Non-trainable params: 0
_________________________________________________________________
Training:Model is trained using Tensorflow and Adam Optimiser on 15 epochs and saved in.h5 model file.
Running Inference without OpenVino:We use Tensorflow's predict
function to test our model.
predictions = model.predict(test_data)
Results:
20 Images takes 7.34 Seconds to Infer.
Average: 0.367 Seconds/ImageRunning Inference with OpenVino:
Installation:
Windows - link
Linux- link
Steps(All are explained in Colab Notebook):
1. Converting.h5 model to.pb (frozen model)
2. Converting.pb (frozen model) to.xml and.bin file required for OpenVino.
3. Running the final inference model usinf OpenVino's Python Libraries.
#importng .xml and .bin file exported in previous step
model_xml = '/content/frozen_model.xml'
model_bin = '/content/frozen_model.bin'
#Selecting CPU fro inference
plugin = IEPlugin("CPU", plugin_dirs=plugin_dir)
net = IENetwork.from_ir(model=model_xml, weights=model_bin)
input_blob = next(iter(net.inputs))
out_blob = next(iter(net.outputs))
# Load network to the plugin
exec_net = plugin.load(network=net)
#Inference
predictions = exec_net.infer(inputs={input_blob: test_data})
Results:
20 Images takes 0.118 Seconds to Infer
Average: 0.0059 Seconds/ImageInference Results :
Shows Percent of Detection of Disease
OpenVino works extremely fast and accurate for inferencing machine learning models.
In my model I got a Boost of 72Times Faster than Normal Inferencing
- Using this model on Drones with Raspberry Pi and Compute Stick
- Adding more features to Model like detecting type of Disease
- Adding more Plants Detection
Comments