dk00069 commited on
Commit
b553823
·
verified ·
1 Parent(s): fa2a026

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +34 -0
app.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import numpy as np
3
+ from tensorflow import keras
4
+ from huggingface_hub import hf_hub_download
5
+
6
+ # Load your model
7
+ model_path = hf_hub_download("dk00069/WasteClassifier01", "waste_classifier_final.h5")
8
+ model = keras.models.load_model(model_path)
9
+
10
+ # Your class labels
11
+ labels = ["Cardboard", "Glass", "Metal", "Paper", "Plastic", "Trash"]
12
+
13
+ def classify(image):
14
+ img = image.resize((224, 224))
15
+ img_array = np.expand_dims(np.array(img) / 255.0, axis=0)
16
+ preds = model.predict(img_array)[0]
17
+ return {labels[i]: float(preds[i]) for i in range(len(labels))}
18
+
19
+ gr.Interface(
20
+ fn=classify,
21
+ inputs=gr.Image(type="pil"),
22
+ outputs=gr.Label(num_top_classes=3),
23
+ title="🗑️ Waste Classifier",
24
+ description="Upload a waste image to classify it!"
25
+ ).launch()
26
+ ```
27
+
28
+ This gives you a **live public demo link** you can share with anyone! 🚀
29
+
30
+ ---
31
+
32
+ ## 🎯 Your Model's Public Link
33
+ ```
34
+ https://huggingface.co/dk00069/WasteClassifier01