Waste Classification Model

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.

Model Details

  • Architecture: Convolutional Neural Network (CNN)
  • Framework: TensorFlow/Keras
  • Input Size: 128ร—128 pixels, RGB (3 channels)
  • Categories: 6 waste types

Classification Categories

The model classifies waste into these categories:

  • Cardboard
  • Glass
  • Metal
  • Paper
  • Plastic
  • Trash

Installation

pip install tensorflow huggingface-hub numpy pillow

Usage

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%}")

Requirements

  • Python 3.7+
  • TensorFlow 2.8+
  • NumPy
  • Pillow
Downloads last month
66
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support