Taidat commited on
Commit
591555f
·
verified ·
1 Parent(s): c4566c8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -6,16 +6,16 @@ from PIL import Image
6
  # Load model
7
  model = tf.keras.models.load_model("model.h5")
8
 
9
- # Define class names — replace with your actual folder names if different
10
- class_names = ['batteries', 'cardboard', 'glass', 'metal', 'paper', 'plastic', 'trash']
11
 
12
- # Define image size used in training
13
  IMG_SIZE = (224, 224)
14
 
15
  def preprocess(image):
16
  image = image.resize(IMG_SIZE)
17
  image_array = tf.keras.preprocessing.image.img_to_array(image)
18
- image_array = image_array / 255.0 # Normalize if you did this during training
19
  return np.expand_dims(image_array, axis=0)
20
 
21
  def predict(image):
 
6
  # Load model
7
  model = tf.keras.models.load_model("model.h5")
8
 
9
+ # Correct class names in training order
10
+ class_names = ['batteries', 'clothes', 'e-waste', 'glass', 'light blubs', 'metal', 'organic', 'paper', 'plastic']
11
 
12
+ # Match training input size
13
  IMG_SIZE = (224, 224)
14
 
15
  def preprocess(image):
16
  image = image.resize(IMG_SIZE)
17
  image_array = tf.keras.preprocessing.image.img_to_array(image)
18
+ image_array = image_array / 255.0 # Normalize if this was done in training
19
  return np.expand_dims(image_array, axis=0)
20
 
21
  def predict(image):