Downloads · 30 days
13
3% of all-time downloads
NeoAivara/waste-classification-model
waste-classification-model is a machine learning model from NeoAivara. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for keras. The card lists the license as apache-2.0.
A Convolutional Neural Network (CNN) built with TensorFlow/Keras for automated waste classification. This model identifies and categorizes different types of waste materials to support recycling and waste management e…
Downloads · 30 days
13
3% of all-time downloads
All-time downloads
376
Public
Repo size
253 MB
Likes
2
Public
Click a slice to open those files.
.keras253 MB · 100%
From the Hugging Face model README
A Convolutional Neural Network (CNN) built with TensorFlow/Keras for automated waste classification. This model identifies and categorizes different types of waste materials to support recycling and waste management efforts.
The model classifies waste into these categories:
pip install tensorflow huggingface-hub numpy pillow
from huggingface_hub import hf_hub_download
import tensorflow as tf
import numpy as np
from tensorflow.keras.preprocessing import image
# Download and load model
repo_id = "MOHAMMED7M7/waste-classification-model"
filename = "waste_classification_model.keras"
model_path = hf_hub_download(repo_id=repo_id, filename=filename)
model = tf.keras.models.load_model(model_path)
# Preprocess image
def preprocess_image(img_path):
img = image.load_img(img_path, target_size=(128, 128))
img_array = image.img_to_array(img)
img_array = np.expand_dims(img_array, axis=0)
img_array /= 255.0
return img_array
# Make prediction
image_path = 'path/to/your/image.jpg'
processed_image = preprocess_image(image_path)
predictions = model.predict(processed_image)
# Get result
class_names = ['cardboard', 'glass', 'metal', 'paper', 'plastic', 'trash']
predicted_class_index = np.argmax(predictions)
predicted_class = class_names[predicted_class_index]
confidence = predictions[0][predicted_class_index]
print(f"Predicted class: {predicted_class}")
print(f"Confidence: {confidence:.2%}")