Recognize if a leave is healthy or not through a single picture
Pandemic is a project that aims to indentify if a leave is healthy or not through a single picture of it. To do so, we're using convolutional neural networks and the dataset from PlantVillage.
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
Make sure you have all of the Python dependencies already installed, including Jupyter and TensorFlow, along with the dataset from PlantVillage. You can either git clone it or use svn to download only the important folders since the repository is way too large, like so:
svn checkout https://github.com/spMohanty/PlantVillage-Dataset/trunk/raw/color/Grape___Esca_\(Black_Measles)First of all, install all of the dependencies:
pip install -r requirements.txtThen create a dataset folder containing two subfolders, those 2 will be the classes that you want to classify later one. In the end, you should have a folder structure like so:
src
βββ balance_data.py
βββ cnn.ipynb
βββ dataset
βΒ Β βββ bad
βΒ Β βββ healthy
βββ load_dataset.py
βββ predict.py
βββ README.md
βββ requirements.txt
In case your dataset is imbalanced (way more data from one class than the other), you can try to augment your data with the balance_data.py script. Change the folder that you want it to work on, then run:
python balance_data.pyThen you can start your Jupyter server with jupyter notebook inside our work folder, open the cnn.ipynb notebook and start to work on it.
If you want to try out a model generated by our previous notebook, you can do so by simply running the predict.py script with the appropriate h5 model. Be aware that the input image needs to be of size 256x256 pixels. A simple way to scale all images, which is commented inside predict.py is:
size = 256, 256
# change this to your actual path
path = "test"
num = 0
for item in os.listdir(path):
file = os.path.join(path, item)
im = Image.open(file)
im = im.resize(size)
im.save(os.path.join(path, (str(num) + ".jpg")))
num += 1
os.remove(file)TODO
