Views
No views yet

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.
1Classification Report:
2 precision recall f1-score support
3
4 aluminium 0.9213 0.9145 0.9179 269
5 batteries 0.9833 0.9933 0.9883 297
6 cardboard 0.9660 0.9343 0.9499 274
7disposable plates 0.9078 0.9744 0.9399 273
8 glass 0.9621 0.9490 0.9555 294
9 hard plastic 0.8675 0.7250 0.7899 280
10 paper 0.8702 0.8941 0.8820 255
11 paper towel 0.9333 0.9622 0.9475 291
12 polystyrene 0.8188 0.8385 0.8285 291
13 soft plastics 0.8425 0.8693 0.8557 283
14 takeaway cups 0.9575 0.9767 0.9670 300
15
16 accuracy 0.9128 3107
17 macro avg 0.9119 0.9119 0.9111 3107
18 weighted avg 0.9127 0.9128 0.9119 3107
!pip install -q transformers torch pillow gradio1import gradio as gr
2from transformers import AutoImageProcessor, SiglipForImageClassification
3from PIL import Image
4import torch
5
6# Load model and processor
7model_name = "prithivMLmods/Recycling-Net-11" # Update with your actual Hugging Face model path
8model = SiglipForImageClassification.from_pretrained(model_name)
9processor = AutoImageProcessor.from_pretrained(model_name)
10
11# Label mapping
12id2label = {
13 0: "aluminium",
14 1: "batteries",
15 2: "cardboard",
16 3: "disposable plates",
17 4: "glass",
18 5: "hard plastic",
19 6: "paper",
20 7: "paper towel",
21 8: "polystyrene",
22 9: "soft plastics",
23 10: "takeaway cups"
24}
25
26def classify_recyclable_material(image):
27 """Predicts the type of recyclable material in the image."""
28 image = Image.fromarray(image).convert("RGB")
29 inputs = processor(images=image, return_tensors="pt")
30
31 with torch.no_grad():
32 outputs = model(**inputs)
33 logits = outputs.logits
34 probs = torch.nn.functional.softmax(logits, dim=1).squeeze().tolist()
35
36 predictions = {id2label[i]: round(probs[i], 3) for i in range(len(probs))}
37 return predictions
38
39# Gradio interface
40iface = gr.Interface(
41 fn=classify_recyclable_material,
42 inputs=gr.Image(type="numpy"),
43 outputs=gr.Label(label="Recyclable Material Prediction Scores"),
44 title="Recycling-Net-11",
45 description="Upload an image of a waste item to identify its recyclable material type."
46)
47
48# Launch the app
49if __name__ == "__main__":
50 iface.launch()