Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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 |
-
#
|
| 10 |
-
class_names = ['batteries', '
|
| 11 |
|
| 12 |
-
#
|
| 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
|
| 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):
|