Spaces:
No application file
No application file
Delete src
Browse files- src/keras_model.h5 +0 -3
- src/labels.txt +0 -5
- src/streamlit_app.py +0 -55
src/keras_model.h5
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:d80bf760a260153e1aa76937e4f82183f188a43c703abd09463e59087b1e7883
|
3 |
-
size 2456608
|
|
|
|
|
|
|
|
src/labels.txt
DELETED
@@ -1,5 +0,0 @@
|
|
1 |
-
0 PLASTICS
|
2 |
-
1 GLASS
|
3 |
-
2 PAPER
|
4 |
-
3 METAL
|
5 |
-
4 CARDBOARD
|
|
|
|
|
|
|
|
|
|
|
|
src/streamlit_app.py
DELETED
@@ -1,55 +0,0 @@
|
|
1 |
-
import os
|
2 |
-
os.environ["HOME"] = "/tmp"
|
3 |
-
import streamlit as st
|
4 |
-
from tensorflow.keras.models import load_model
|
5 |
-
from tensorflow.keras.layers import DepthwiseConv2D
|
6 |
-
from PIL import Image, ImageOps
|
7 |
-
import numpy as np
|
8 |
-
|
9 |
-
# Optional: Patch DepthwiseConv2D if needed
|
10 |
-
class PatchedDepthwiseConv2D(DepthwiseConv2D):
|
11 |
-
def __init__(self, *args, groups=1, **kwargs):
|
12 |
-
super().__init__(*args, **kwargs)
|
13 |
-
|
14 |
-
# Load model
|
15 |
-
model = load_model(r"src/keras_model.h5", compile=False, custom_objects={"DepthwiseConv2D": PatchedDepthwiseConv2D})
|
16 |
-
|
17 |
-
# Load class labels
|
18 |
-
with open(r"src/labels.txt", "r") as f:
|
19 |
-
class_names = f.readlines()
|
20 |
-
|
21 |
-
st.title("♻️ Garbage Classification Predictor")
|
22 |
-
|
23 |
-
# Upload image
|
24 |
-
uploaded_file = st.file_uploader("Upload a waste image (jpg, png)", type=["jpg", "jpeg", "png"])
|
25 |
-
|
26 |
-
if st.button("🧪 Predict Waste Type"):
|
27 |
-
if uploaded_file is not None:
|
28 |
-
image = Image.open(uploaded_file)
|
29 |
-
st.image(image, use_container_width=True)
|
30 |
-
|
31 |
-
|
32 |
-
# Preprocess image
|
33 |
-
image = image.convert("RGB")
|
34 |
-
image = ImageOps.fit(image, (224, 224), Image.Resampling.LANCZOS)
|
35 |
-
image_array = np.asarray(image)
|
36 |
-
normalized_image_array = (image_array.astype(np.float32) / 127.5) - 1
|
37 |
-
data = np.ndarray(shape=(1, 224, 224, 3), dtype=np.float32)
|
38 |
-
data[0] = normalized_image_array
|
39 |
-
|
40 |
-
# Make prediction
|
41 |
-
prediction = model.predict(data)
|
42 |
-
index = np.argmax(prediction)
|
43 |
-
predicted_label = class_names[index].strip()
|
44 |
-
confidence = prediction[0][index]
|
45 |
-
|
46 |
-
# Display result
|
47 |
-
st.success(f"Predicted Waste Type: **{predicted_label.upper()}**")
|
48 |
-
st.write(f"Confidence Score: **{confidence:.2f}**")
|
49 |
-
st.write("♻️ Dispose responsibly!")
|
50 |
-
else:
|
51 |
-
st.warning("⚠️ Please upload an image before predicting.")
|
52 |
-
# 🔚 Footer
|
53 |
-
st.markdown("---")
|
54 |
-
st.markdown("<p style='text-align: center; font-size: 18px;'>Developed for EDUNET FOUNDATION </p>", unsafe_allow_html=True)
|
55 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|