├── DanLeaf2.jpg ├── LICENSE ├── Leaf_Deases (1).ipynb ├── Make API.py ├── README.md ├── Request api.py ├── Screenshot.png ├── main.py └── requirements.txt /DanLeaf2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProgrammeChef/leaf-diseases-detect/6099a9b289158836f266825ff80112ed5f540da0/DanLeaf2.jpg -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 shukur-alom 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Make API.py: -------------------------------------------------------------------------------- 1 | from flask import Flask, request, jsonify 2 | from tensorflow.keras.models import load_model 3 | import numpy as np 4 | 5 | leaf_deases_model = load_model('/home/shukur/Documents/Python Code/Tree Deases/Leaf_Deases(95,88).h5') 6 | 7 | label_name = ['Apple scab','Apple Black rot', 'Apple Cedar apple rust', 'Apple healthy', 'Cherry Powdery mildew', 8 | 'Cherry healthy','Corn Cercospora leaf spot Gray leaf spot', 'Corn Common rust', 'Corn Northern Leaf Blight','Corn healthy', 9 | 'Grape Black rot', 'Grape Esca', 'Grape Leaf blight', 'Grape healthy','Peach Bacterial spot','Peach healthy', 'Pepper bell Bacterial spot', 10 | 'Pepper bell healthy', 'Potato Early blight', 'Potato Late blight', 'Potato healthy', 'Strawberry Leaf scorch', 'Strawberry healthy', 11 | 'Tomato Bacterial spot', 'Tomato Early blight', 'Tomato Late blight', 'Tomato Leaf Mold', 'Tomato Septoria leaf spot', 12 | 'Tomato Spider mites', 'Tomato Target Spot', 'Tomato Yellow Leaf Curl Virus', 'Tomato mosaic virus', 'Tomato healthy'] 13 | 14 | app = Flask(__name__) 15 | 16 | @app.route("/",methods=['POST']) 17 | def just(): 18 | data = request.json 19 | img = np.array(data['img']) 20 | 21 | pridict_image = leaf_deases_model.predict(img.reshape((1,) + img.shape )) 22 | 23 | return jsonify({"Label Name":label_name[np.argmax(pridict_image)], 24 | "Accuracy": pridict_image[0][np.argmax(pridict_image)]*100}) 25 | 26 | if __name__ == "__main__": 27 | app.run(debug=True) -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Leaf Disease Detection using Deep Learning 2 | 3 | This project is a leaf disease detection system that uses deep learning techniques, including transfer learning, to identify and classify 33 different types of leaf diseases. The model has been trained on a large dataset of images and is designed to help agricultural professionals and enthusiasts diagnose plant diseases in a fast and accurate manner. 4 | 5 | ## Model Download 6 | 7 | You can download the pre-trained leaf disease detection model from the following link: 8 | 9 | [Leaf Disease Detection Model](https://drive.google.com/file/d/11BAit2Oc98PRxY_x6kOwKY9TTbIlurrB/view?usp=sharing) 10 | 11 | ## Usage 12 | 13 | To use the model for leaf disease detection, follow these steps: 14 | 15 | 1. Download the pre-trained model using the link provided above. 16 | 2. Make sure you have a Python environment set up with the necessary libraries installed. You can use the provided requirements.txt file to set up the required dependencies. 17 | 18 | ``` 19 | pip install -r requirements.txt 20 | ``` 21 | 22 | 2. Run main.py 23 | 24 | ``` 25 | python main.py 26 | ``` 27 | 28 | ## Model Details 29 | The leaf disease detection model is built using deep learning techniques, and it uses transfer learning to leverage the pre-trained knowledge of a base model. The model is trained on a dataset containing images of 33 different types of leaf diseases. For more information about the architecture, dataset, and training process, please refer to the code and documentation provided. 30 | 31 | 32 | ## Acknowledgments 33 | We would like to acknowledge the contributions of the open-source community and the creators of the base model that this project builds upon. Your work and support are greatly appreciated. 34 | -------------------------------------------------------------------------------- /Request api.py: -------------------------------------------------------------------------------- 1 | import requests 2 | import numpy as np 3 | from keras.preprocessing.image import load_img,img_to_array 4 | 5 | url = 'http://127.0.0.1:5000/' 6 | 7 | img = img_to_array(load_img('DanLeaf2.jpg',target_size=(150,150,3))) 8 | 9 | r = requests.post(url, json={'img':img.tolist()}) 10 | 11 | print(f"\n\n{r.json()}\n\n") -------------------------------------------------------------------------------- /Screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProgrammeChef/leaf-diseases-detect/6099a9b289158836f266825ff80112ed5f540da0/Screenshot.png -------------------------------------------------------------------------------- /main.py: -------------------------------------------------------------------------------- 1 | from tensorflow.keras.models import load_model 2 | from tensorflow.keras.preprocessing.image import load_img,img_to_array 3 | import numpy as np 4 | 5 | 6 | leaf_deases_model = load_model('/home/shukur/Documents/Python Code/Tree Deases/Leaf_Deases(95,88).h5') 7 | 8 | label_name = ['Apple scab','Apple Black rot', 'Apple Cedar apple rust', 'Apple healthy', 'Cherry Powdery mildew', 9 | 'Cherry healthy','Corn Cercospora leaf spot Gray leaf spot', 'Corn Common rust', 'Corn Northern Leaf Blight','Corn healthy', 10 | 'Grape Black rot', 'Grape Esca', 'Grape Leaf blight', 'Grape healthy','Peach Bacterial spot','Peach healthy', 'Pepper bell Bacterial spot', 11 | 'Pepper bell healthy', 'Potato Early blight', 'Potato Late blight', 'Potato healthy', 'Strawberry Leaf scorch', 'Strawberry healthy', 12 | 'Tomato Bacterial spot', 'Tomato Early blight', 'Tomato Late blight', 'Tomato Leaf Mold', 'Tomato Septoria leaf spot', 13 | 'Tomato Spider mites', 'Tomato Target Spot', 'Tomato Yellow Leaf Curl Virus', 'Tomato mosaic virus', 'Tomato healthy'] 14 | 15 | 16 | path = input('Imag Path') 17 | img = img_to_array(load_img(path,target_size=(150,150,3))) 18 | 19 | pridict_image = leaf_deases_model.predict( img.reshape((1,) + img.shape )) 20 | 21 | print(f"{label_name[np.argmax(pridict_image)]} {pridict_image[0][np.argmax(pridict_image)]*100}%") -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | Python 3.8.5 2 | tensorflow==2.3.1 3 | numpy==1.18.5 4 | keras==2.4.3 5 | matplotlib==3.3.2 6 | sklearn==0.0 7 | flask==1.1.2 8 | --------------------------------------------------------------------------------