Taidat commited on
Commit
ab6d965
·
verified ·
1 Parent(s): 317d275

Upload 5 files

Browse files
Files changed (5) hide show
  1. README.md +29 -0
  2. app.py +29 -0
  3. requirements.txt +4 -0
  4. runtime.txt +1 -0
  5. waste_classifier_finetuned.h5 +3 -0
README.md ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: Smart Waste Classifier ♻️
3
+ emoji: ♻️
4
+ colorFrom: green
5
+ colorTo: blue
6
+ sdk: gradio
7
+ sdk_version: "3.50.2"
8
+ app_file: app.py
9
+ pinned: false
10
+ ---
11
+
12
+ # Smart Waste Classifier ♻️
13
+
14
+ This project classifies recyclable waste into categories using a fine-tuned MobileNetV2 model with TensorFlow and Gradio.
15
+
16
+ ## How to Use
17
+
18
+ Upload an image of waste (e.g., plastic bottle, metal can, glass) and the model predicts its category.
19
+
20
+ ## Model Info
21
+
22
+ - Backbone: MobileNetV2
23
+ - Framework: TensorFlow
24
+ - Interface: Gradio
25
+ - Deployment: Hugging Face Spaces
26
+
27
+ ---
28
+
29
+ Upload the included `model.h5` file along with this app to your Hugging Face Space to deploy it live.
app.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import tensorflow as tf
3
+ import numpy as np
4
+
5
+ # Load model
6
+ model = tf.keras.models.load_model("model.h5")
7
+ IMG_SIZE = (224, 224)
8
+
9
+ # Class labels
10
+ index_to_label = {
11
+ 0: "paper", 1: "e-waste", 2: "metal", 3: "light blubs",
12
+ 4: "organic", 5: "plastic", 6: "clothes", 7: "glass", 8: "batteries"
13
+ }
14
+
15
+ def classify_image(img):
16
+ img = tf.image.resize(img, IMG_SIZE)
17
+ img = tf.expand_dims(img, axis=0)
18
+ img = tf.cast(img, tf.float32) / 255.0
19
+ pred = model.predict(img)[0]
20
+ return {index_to_label[i]: float(pred[i]) for i in range(len(pred))}
21
+
22
+ demo = gr.Interface(
23
+ fn=classify_image,
24
+ inputs=gr.Image(type="numpy", label="Upload Waste Image"),
25
+ outputs=gr.Label(num_top_classes=3),
26
+ title="Smart Waste Classifier"
27
+ )
28
+
29
+ demo.launch()
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ gradio==3.50.2
2
+ tensorflow-cpu==2.13.0
3
+ numpy
4
+ matplotlib
runtime.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ python-3.10
waste_classifier_finetuned.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bad621ebbecba4fed829ed92b377eb28cd4e1680346ccbb3d89db6ca45818e77
3
+ size 23622640