Hemant0000 commited on
Commit
6d77b63
·
verified ·
1 Parent(s): c8c6ad9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -94,7 +94,7 @@ plt.legend(['Train', 'Validation'], loc='upper left')
94
  plt.show()
95
 
96
  # Assuming you have a test directory
97
- test_dir = '/content/drive/MyDrive/Tomato_Plant_Disease' # Path to your test dataset
98
 
99
  # Create a test data generator (without augmentation)
100
  test_datagen = ImageDataGenerator(rescale=1./255)
@@ -110,7 +110,7 @@ test_generator = test_datagen.flow_from_directory(
110
  test_loss, test_acc = model.evaluate(test_generator, steps=test_generator.samples // 32)
111
  print(f"Test Accuracy: {test_acc}")
112
 
113
- model.save('/content/drive/MyDrive/tomato_disease_detection_model.h5')
114
 
115
  from tensorflow.keras.models import load_model
116
  from tensorflow.keras.preprocessing import image
@@ -118,7 +118,7 @@ import numpy as np
118
  from PIL import Image
119
 
120
  # Load the model
121
- model = load_model('/content/drive/MyDrive/tomato_disease_detection_model.h5')
122
 
123
  def predict_disease(img_path):
124
  # Load and preprocess the image
@@ -138,7 +138,7 @@ def predict_disease(img_path):
138
  print("The plant is infected.")
139
 
140
  # Example usage:
141
- img_path = '/content/drive/MyDrive/Tomato_Plant_Disease/0/0045ba29-ed1b-43b4-afde-719cc7adefdb___GCREC_Bact.Sp 6254.JPG'
142
  predict_disease(img_path)
143
 
144
  import gradio as gr
@@ -147,7 +147,7 @@ from PIL import Image
147
  import numpy as np
148
 
149
  # Load the pre-trained model
150
- model = load_model('/content/drive/MyDrive/tomato_disease_detection_model.h5')
151
 
152
  # Prediction function to be used in Gradio
153
  def predict_disease(img):
 
94
  plt.show()
95
 
96
  # Assuming you have a test directory
97
+ test_dir = 'Tomato_Plant_Disease' # Path to your test dataset
98
 
99
  # Create a test data generator (without augmentation)
100
  test_datagen = ImageDataGenerator(rescale=1./255)
 
110
  test_loss, test_acc = model.evaluate(test_generator, steps=test_generator.samples // 32)
111
  print(f"Test Accuracy: {test_acc}")
112
 
113
+ model.save('tomato_disease_detection_model.h5')
114
 
115
  from tensorflow.keras.models import load_model
116
  from tensorflow.keras.preprocessing import image
 
118
  from PIL import Image
119
 
120
  # Load the model
121
+ model = load_model('tomato_disease_detection_model.h5')
122
 
123
  def predict_disease(img_path):
124
  # Load and preprocess the image
 
138
  print("The plant is infected.")
139
 
140
  # Example usage:
141
+ img_path = 'Tomato_Plant_Disease/0/0045ba29-ed1b-43b4-afde-719cc7adefdb___GCREC_Bact.Sp 6254.JPG'
142
  predict_disease(img_path)
143
 
144
  import gradio as gr
 
147
  import numpy as np
148
 
149
  # Load the pre-trained model
150
+ model = load_model('tomato_disease_detection_model.h5')
151
 
152
  # Prediction function to be used in Gradio
153
  def predict_disease(img):