File size: 1,951 Bytes
d017839 5b50e81 db944bb 5b50e81 db944bb 5b50e81 db944bb 5b50e81 db944bb 5b50e81 db944bb 5b50e81 db944bb 5b50e81 db944bb 5b50e81 db944bb 5b50e81 db944bb 5b50e81 db944bb 5b50e81 db944bb 5b50e81 db944bb 5b50e81 db944bb 5b50e81 db944bb 5b50e81 db944bb 5b50e81 db944bb d017839 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
---
license: apache-2.0
language:
- en
library_name: keras
tags:
- ecology
---
# 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
```bash
pip install tensorflow huggingface-hub numpy pillow
```
## Usage
```python
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 |