Update README.md
Browse files
README.md
CHANGED
|
@@ -4,6 +4,11 @@ datasets:
|
|
| 4 |
- viola77data/recycling-dataset
|
| 5 |
library_name: transformers
|
| 6 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
```py
|
| 8 |
Classification Report:
|
| 9 |
precision recall f1-score support
|
|
@@ -25,4 +30,91 @@ disposable plates 0.9078 0.9744 0.9399 273
|
|
| 25 |
weighted avg 0.9127 0.9128 0.9119 3107
|
| 26 |
```
|
| 27 |
|
| 28 |
-

|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
- viola77data/recycling-dataset
|
| 5 |
library_name: transformers
|
| 6 |
---
|
| 7 |
+
|
| 8 |
+
# **Recycling-Net-11**
|
| 9 |
+
|
| 10 |
+
> **Recycling-Net-11** is an image classification model fine-tuned from **google/siglip2-base-patch16-224** using the **SiglipForImageClassification** architecture. The model classifies images into 11 categories related to recyclable materials, helping to automate and enhance waste sorting systems.
|
| 11 |
+
|
| 12 |
```py
|
| 13 |
Classification Report:
|
| 14 |
precision recall f1-score support
|
|
|
|
| 30 |
weighted avg 0.9127 0.9128 0.9119 3107
|
| 31 |
```
|
| 32 |
|
| 33 |
+

|
| 34 |
+
|
| 35 |
+
The model categorizes images into the following classes:
|
| 36 |
+
|
| 37 |
+
- **0:** aluminium
|
| 38 |
+
- **1:** batteries
|
| 39 |
+
- **2:** cardboard
|
| 40 |
+
- **3:** disposable plates
|
| 41 |
+
- **4:** glass
|
| 42 |
+
- **5:** hard plastic
|
| 43 |
+
- **6:** paper
|
| 44 |
+
- **7:** paper towel
|
| 45 |
+
- **8:** polystyrene
|
| 46 |
+
- **9:** soft plastics
|
| 47 |
+
- **10:** takeaway cups
|
| 48 |
+
|
| 49 |
+
---
|
| 50 |
+
|
| 51 |
+
# **Run with Transformers 🤗**
|
| 52 |
+
|
| 53 |
+
```python
|
| 54 |
+
!pip install -q transformers torch pillow gradio
|
| 55 |
+
```
|
| 56 |
+
|
| 57 |
+
```python
|
| 58 |
+
import gradio as gr
|
| 59 |
+
from transformers import AutoImageProcessor, SiglipForImageClassification
|
| 60 |
+
from PIL import Image
|
| 61 |
+
import torch
|
| 62 |
+
|
| 63 |
+
# Load model and processor
|
| 64 |
+
model_name = "prithivMLmods/Recycling-Net-11" # Update with your actual Hugging Face model path
|
| 65 |
+
model = SiglipForImageClassification.from_pretrained(model_name)
|
| 66 |
+
processor = AutoImageProcessor.from_pretrained(model_name)
|
| 67 |
+
|
| 68 |
+
# Label mapping
|
| 69 |
+
id2label = {
|
| 70 |
+
0: "aluminium",
|
| 71 |
+
1: "batteries",
|
| 72 |
+
2: "cardboard",
|
| 73 |
+
3: "disposable plates",
|
| 74 |
+
4: "glass",
|
| 75 |
+
5: "hard plastic",
|
| 76 |
+
6: "paper",
|
| 77 |
+
7: "paper towel",
|
| 78 |
+
8: "polystyrene",
|
| 79 |
+
9: "soft plastics",
|
| 80 |
+
10: "takeaway cups"
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
def classify_recyclable_material(image):
|
| 84 |
+
"""Predicts the type of recyclable material in the image."""
|
| 85 |
+
image = Image.fromarray(image).convert("RGB")
|
| 86 |
+
inputs = processor(images=image, return_tensors="pt")
|
| 87 |
+
|
| 88 |
+
with torch.no_grad():
|
| 89 |
+
outputs = model(**inputs)
|
| 90 |
+
logits = outputs.logits
|
| 91 |
+
probs = torch.nn.functional.softmax(logits, dim=1).squeeze().tolist()
|
| 92 |
+
|
| 93 |
+
predictions = {id2label[i]: round(probs[i], 3) for i in range(len(probs))}
|
| 94 |
+
return predictions
|
| 95 |
+
|
| 96 |
+
# Gradio interface
|
| 97 |
+
iface = gr.Interface(
|
| 98 |
+
fn=classify_recyclable_material,
|
| 99 |
+
inputs=gr.Image(type="numpy"),
|
| 100 |
+
outputs=gr.Label(label="Recyclable Material Prediction Scores"),
|
| 101 |
+
title="Recycling-Net-11",
|
| 102 |
+
description="Upload an image of a waste item to identify its recyclable material type."
|
| 103 |
+
)
|
| 104 |
+
|
| 105 |
+
# Launch the app
|
| 106 |
+
if __name__ == "__main__":
|
| 107 |
+
iface.launch()
|
| 108 |
+
```
|
| 109 |
+
|
| 110 |
+
---
|
| 111 |
+
|
| 112 |
+
# **Intended Use**
|
| 113 |
+
|
| 114 |
+
**Recycling-Net-11** is ideal for:
|
| 115 |
+
|
| 116 |
+
- **Smart Waste Sorting:** Automating recycling processes in smart bins or factories.
|
| 117 |
+
- **Environmental Awareness Tools:** Helping people learn how to sort waste correctly.
|
| 118 |
+
- **Municipal Waste Management:** Classifying and analyzing urban waste data.
|
| 119 |
+
- **Robotics:** Assisting robots in identifying and sorting materials.
|
| 120 |
+
- **Education:** Teaching children and communities about recyclable materials.
|