vignesh456 commited on
Commit
ec2e2b9
·
verified ·
1 Parent(s): 2cc977b

Update streamlit_app.py

Browse files
Files changed (1) hide show
  1. streamlit_app.py +3 -19
streamlit_app.py CHANGED
@@ -7,27 +7,11 @@ st.title('🍅 Simple Tomato Leaf Disease Classifier')
7
 
8
  @st.cache_resource
9
  def load_model():
10
- # Define the same model architecture as in training
11
- model = tf.keras.models.Sequential([
12
- tf.keras.layers.Conv2D(32, (3, 3), input_shape=(128, 128, 3), activation='relu'),
13
- tf.keras.layers.MaxPooling2D(pool_size=(2, 2)),
14
- tf.keras.layers.Conv2D(16, (3, 3), activation='relu'),
15
- tf.keras.layers.MaxPooling2D(pool_size=(2, 2)),
16
- tf.keras.layers.Conv2D(8, (3, 3), activation='relu'),
17
- tf.keras.layers.MaxPooling2D(pool_size=(2, 2)),
18
- tf.keras.layers.Flatten(),
19
- tf.keras.layers.Dense(128, activation='relu'),
20
- tf.keras.layers.Dropout(0.5),
21
- tf.keras.layers.Dense(10, activation='softmax')
22
- ])
23
-
24
- # Load only the weights (not the full saved model)
25
- model.load_weights('100-epoch with regularization.h5')
26
- return model
27
 
28
  model = load_model()
29
 
30
- # Class labels
31
  class_names = [
32
  'Tomato___Bacterial_spot',
33
  'Tomato___Early_blight',
@@ -51,4 +35,4 @@ if uploaded_file is not None:
51
  img_array = np.expand_dims(img_array, axis=0)
52
  preds = model.predict(img_array)
53
  pred_class = np.argmax(preds, axis=1)[0]
54
- st.success(f'Predicted Class: {class_names[pred_class]}')
 
7
 
8
  @st.cache_resource
9
  def load_model():
10
+ return tf.keras.models.load_model('100-epoch with regularization.h5')
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
 
12
  model = load_model()
13
 
14
+ # Class names (update if your classes are different)
15
  class_names = [
16
  'Tomato___Bacterial_spot',
17
  'Tomato___Early_blight',
 
35
  img_array = np.expand_dims(img_array, axis=0)
36
  preds = model.predict(img_array)
37
  pred_class = np.argmax(preds, axis=1)[0]
38
+ st.success(f'Predicted Class: {class_names[pred_class]}')