Views
No views yet
1import tensorflow as tf
2from PIL import Image
3import numpy as np
4
5# Load model
6model = tf.keras.models.load_model('ecodetect_model.h5')
7
8# Preprocess image
9image = Image.open('waste_image.jpg').resize((124, 124))
10image_array = np.array(image) / 255.0
11image_array = np.expand_dims(image_array, axis=0)
12
13# Predict
14predictions = model.predict(image_array)
15classes = ['cardboard', 'glass', 'metal', 'paper', 'plastic', 'trash']
16predicted_class = classes[np.argmax(predictions)]