amariayudha commited on
Commit
c9c73fb
·
verified ·
1 Parent(s): ac0c571

Upload 37 files

Browse files
app.py CHANGED
@@ -4,6 +4,7 @@ import streamlit as st
4
  import eda
5
  import prediction
6
 
 
7
  st.set_page_config(
8
  page_title="Waste Classification",
9
  page_icon="♻️",
@@ -12,13 +13,15 @@ st.set_page_config(
12
  )
13
 
14
  def main():
 
15
  st.sidebar.title("♻️ Navigation")
16
  page = st.sidebar.radio("Go to", ["🏠 Home", "📊 EDA", "🔍 Prediction"])
17
 
18
  if page == "🏠 Home":
 
19
  st.sidebar.markdown("---")
20
  st.sidebar.subheader("📊 About the Model")
21
- accuracy = 0.80
22
  st.sidebar.write("🎯 Model Accuracy:")
23
  st.sidebar.progress(accuracy)
24
  st.sidebar.write(f"{accuracy:.2%}")
@@ -28,9 +31,23 @@ def main():
28
  st.sidebar.write(f"Our model correctly classifies {accuracy:.2%} of waste items, helping improve recycling efficiency.")
29
 
30
  st.sidebar.markdown("---")
31
- st.sidebar.subheader("♻️ Fun Fact")
32
- st.sidebar.info("Proper waste classification can increase recycling rates by up to 50%!")
 
 
 
 
 
 
 
 
 
 
 
 
 
33
 
 
34
  st.title("♻️ Welcome to Waste Classification Tool")
35
  st.write("""
36
  This application provides functionalities for Exploratory Data Analysis and
@@ -38,36 +55,61 @@ def main():
38
  select the module you wish to utilize.
39
  """)
40
 
 
41
  col1, col2, col3 = st.columns([1,2,1])
42
  with col2:
43
  st.image("https://assets-a1.kompasiana.com/items/album/2021/03/14/dr-stone-fandomcom-1536x864-604dff978ede483a3b589c96.png?t=o&v=780",
44
- caption="Notes : Recycle is important for our environment", use_column_width=True)
45
 
46
  st.markdown("---")
47
 
 
48
  st.write("#### 📊 Dataset")
49
  st.info("""
50
  The dataset used is the RealWaste dataset, containing images of waste items across 9 major material types,
51
- collected within an authentic landfill environment.
 
52
  """)
53
 
 
54
  st.write("#### ⚠️ Problem Statement")
55
  st.warning("""
56
  Manual waste sorting is inefficient, leading to low recycling rates and increased environmental harm.
57
  Our goal is to develop a deep learning-based waste classification system using a Convolutional Neural Network (CNN)
58
- that can accurately classify at least 70% of waste images across 9 material categories.
 
 
59
  """)
60
 
 
61
  st.write("#### 🎯 Objective")
62
  st.success("""
63
- This project aims to develop a CNN model capable of accurately classifying waste images into distinct material types,
64
- improving waste management efficiency and environmental sustainability.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65
  """)
66
 
67
  elif page == "📊 EDA":
 
68
  eda.run()
69
 
70
  elif page == "🔍 Prediction":
 
71
  prediction.run()
72
 
73
  if __name__ == "__main__":
 
4
  import eda
5
  import prediction
6
 
7
+ # Set the page configuration for the Streamlit app
8
  st.set_page_config(
9
  page_title="Waste Classification",
10
  page_icon="♻️",
 
13
  )
14
 
15
  def main():
16
+ # Create a sidebar for navigation
17
  st.sidebar.title("♻️ Navigation")
18
  page = st.sidebar.radio("Go to", ["🏠 Home", "📊 EDA", "🔍 Prediction"])
19
 
20
  if page == "🏠 Home":
21
+ # Add sidebar content for the Home page
22
  st.sidebar.markdown("---")
23
  st.sidebar.subheader("📊 About the Model")
24
+ accuracy = 0.82
25
  st.sidebar.write("🎯 Model Accuracy:")
26
  st.sidebar.progress(accuracy)
27
  st.sidebar.write(f"{accuracy:.2%}")
 
31
  st.sidebar.write(f"Our model correctly classifies {accuracy:.2%} of waste items, helping improve recycling efficiency.")
32
 
33
  st.sidebar.markdown("---")
34
+ st.sidebar.subheader("♻️ Fun Facts")
35
+ # Added more fun facts
36
+ fun_facts = [
37
+ "Proper waste classification can increase recycling rates by up to 50%!",
38
+ "Recycling one aluminum can saves enough energy to run a TV for three hours.",
39
+ "It takes 450 years for a plastic bottle to decompose in a landfill.",
40
+ "Glass can be recycled endlessly without losing quality or purity.",
41
+ "Recycling paper saves 17 trees and 7,000 gallons of water per ton of paper."
42
+ ]
43
+ st.sidebar.info(fun_facts[st.session_state.get('fun_fact_index', 0)])
44
+
45
+ # Button to cycle through fun facts
46
+ if st.sidebar.button("Next Fun Fact"):
47
+ st.session_state['fun_fact_index'] = (st.session_state.get('fun_fact_index', 0) + 1) % len(fun_facts)
48
+ st.experimental_rerun()
49
 
50
+ # Main content for the Home page
51
  st.title("♻️ Welcome to Waste Classification Tool")
52
  st.write("""
53
  This application provides functionalities for Exploratory Data Analysis and
 
55
  select the module you wish to utilize.
56
  """)
57
 
58
+ # Display an image in the center column
59
  col1, col2, col3 = st.columns([1,2,1])
60
  with col2:
61
  st.image("https://assets-a1.kompasiana.com/items/album/2021/03/14/dr-stone-fandomcom-1536x864-604dff978ede483a3b589c96.png?t=o&v=780",
62
+ caption="Notes: Recycling is crucial for our environment", use_column_width=True)
63
 
64
  st.markdown("---")
65
 
66
+ # Information about the dataset
67
  st.write("#### 📊 Dataset")
68
  st.info("""
69
  The dataset used is the RealWaste dataset, containing images of waste items across 9 major material types,
70
+ collected within an authentic landfill environment. This dataset provides a realistic representation of
71
+ waste items, allowing our model to learn from real-world examples.
72
  """)
73
 
74
+ # Problem statement
75
  st.write("#### ⚠️ Problem Statement")
76
  st.warning("""
77
  Manual waste sorting is inefficient, leading to low recycling rates and increased environmental harm.
78
  Our goal is to develop a deep learning-based waste classification system using a Convolutional Neural Network (CNN)
79
+ that can accurately classify at least 70% of waste images across 9 material categories. This automated
80
+ system aims to significantly improve recycling efficiency and reduce the environmental impact of improper
81
+ waste disposal.
82
  """)
83
 
84
+ # Project objective
85
  st.write("#### 🎯 Objective")
86
  st.success("""
87
+ This project aims to develop a Convolutional Neural Network (CNN) model capable of accurately classifying waste images into nine distinct material types:
88
+ 1. Cardboard - e.g., boxes, packaging
89
+ 2. Glass - e.g., bottles, jars
90
+ 3. Metal - e.g., cans, foil
91
+ 4. Paper - e.g., newspapers, magazines
92
+ 5. Plastic - e.g., bottles, containers
93
+ 6. Miscellaneous Trash - e.g., non-recyclable items
94
+ 7. Food Organics - e.g., fruit peels, vegetable scraps
95
+ 8. Textile Trash - e.g., old clothes, fabrics
96
+ 9. Vegetation - e.g., leaves, branches
97
+
98
+ By leveraging deep learning techniques, we seek to automate and improve waste management efficiency, ultimately contributing to environmental sustainability. Our model will analyze visual characteristics such as shape, color, and texture to categorize waste items, helping to streamline recycling processes and reduce the environmental impact of improper waste disposal.
99
+
100
+ The successful implementation of this project could lead to:
101
+ - Increased recycling rates
102
+ - Reduced contamination in recycling streams
103
+ - Lower operational costs for waste management facilities
104
+ - Enhanced public awareness about proper waste sorting
105
  """)
106
 
107
  elif page == "📊 EDA":
108
+ # Run the Exploratory Data Analysis module
109
  eda.run()
110
 
111
  elif page == "🔍 Prediction":
112
+ # Run the Prediction module
113
  prediction.run()
114
 
115
  if __name__ == "__main__":
eda.py CHANGED
@@ -1,5 +1,6 @@
1
  # eda.py
2
 
 
3
  import streamlit as st
4
  import pandas as pd
5
  import plotly.express as px
@@ -7,6 +8,7 @@ import matplotlib.pyplot as plt
7
  import seaborn as sns
8
  import numpy as np
9
 
 
10
  @st.cache_data
11
  def load_data():
12
  return pd.DataFrame({
@@ -14,33 +16,74 @@ def load_data():
14
  'Number of Images': [921, 790, 500, 495, 461, 436, 420, 411, 318]
15
  })
16
 
 
17
  def run():
18
  st.title('📊 Exploratory Data Analysis - Waste Classification')
19
 
 
20
  data = load_data()
21
 
22
- if st.checkbox('Show dataset info'):
23
- st.subheader("Dataset Information")
24
- st.write(data)
25
-
26
- st.write("The dataset shows an uneven distribution across the nine waste categories. "
27
- "This imbalance may impact model performance and will need to be addressed during the model training phase.")
28
-
29
- st.subheader("Distribution of Waste Categories")
30
- fig = px.bar(data, x='Class', y='Number of Images', color='Class',
31
- title='Number of Images per Waste Category')
32
- st.plotly_chart(fig)
33
 
34
- st.write("This chart shows the distribution of images across different waste categories. "
35
- "Plastic and Metal categories have significantly more images, which could lead to bias in the model.")
 
 
 
 
 
 
 
 
36
 
 
 
 
 
37
 
38
- st.subheader("Sample Images")
39
- st.write("Here are sample images from each waste category:")
 
 
40
 
41
- st.subheader("Image Size Distribution")
42
- st.write("All images in the dataset have a resolution of 524x524 pixels.")
43
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
 
 
45
  if __name__ == "__main__":
46
  run()
 
1
  # eda.py
2
 
3
+ # Import necessary libraries
4
  import streamlit as st
5
  import pandas as pd
6
  import plotly.express as px
 
8
  import seaborn as sns
9
  import numpy as np
10
 
11
+ # Function to load data with caching for performance
12
  @st.cache_data
13
  def load_data():
14
  return pd.DataFrame({
 
16
  'Number of Images': [921, 790, 500, 495, 461, 436, 420, 411, 318]
17
  })
18
 
19
+ # Main function to run the Streamlit app
20
  def run():
21
  st.title('📊 Exploratory Data Analysis - Waste Classification')
22
 
23
+ # Load the data
24
  data = load_data()
25
 
26
+ # Create a selectbox for users to choose visualization
27
+ visualization_option = st.selectbox(
28
+ "Choose a visualization:",
29
+ ("Dataset Information and Distribution", "Sample Images")
30
+ )
 
 
 
 
 
 
31
 
32
+ if visualization_option == "Dataset Information and Distribution":
33
+ st.subheader("Dataset Information and Distribution")
34
+
35
+ # Add checkbox for showing dataset information
36
+ show_dataset_info = st.checkbox("Show Dataset Information", value=True)
37
+
38
+ if show_dataset_info:
39
+ st.write(data)
40
+ st.write("The dataset shows an uneven distribution across the nine waste categories. "
41
+ "This imbalance may impact model performance and will need to be addressed during the model training phase.")
42
 
43
+ # Bar chart
44
+ fig_bar = px.bar(data, x='Class', y='Number of Images', color='Class',
45
+ title='Number of Images per Waste Category')
46
+ st.plotly_chart(fig_bar, use_container_width=True)
47
 
48
+ # Pie chart
49
+ fig_pie = px.pie(data, values='Number of Images', names='Class',
50
+ title='Proportion of Images per Waste Category')
51
+ st.plotly_chart(fig_pie, use_container_width=True)
52
 
53
+ st.write("These charts show the distribution of images across different waste categories. "
54
+ "Plastic and Metal categories have significantly more images, which could lead to bias in the model.")
55
 
56
+ elif visualization_option == "Sample Images":
57
+ st.subheader("Sample Images")
58
+ st.write("Here are sample images from each waste category:")
59
+
60
+ categories = ['cardboard', 'food_organics', 'glass', 'metal', 'misc', 'paper', 'plastic', 'textile', 'vegetation']
61
+
62
+ # Create a selectbox for choosing a specific category
63
+ selected_category = st.selectbox("Select a waste category:", categories)
64
+
65
+ st.write(f"**{selected_category.capitalize()}**")
66
+
67
+ cols = st.columns(3)
68
+ for i in range(1, 4):
69
+ with cols[i-1]:
70
+ img_path = f'./visualization/{selected_category} ({i}).jpg'
71
+ st.image(img_path, caption=f'{selected_category.capitalize()} ({i})', use_column_width=True)
72
+
73
+ st.write("These sample images provide a visual representation of the selected waste category in our dataset.")
74
+
75
+ # Add an option to view all categories
76
+ if st.checkbox("View all categories"):
77
+ for category in categories:
78
+ if category != selected_category:
79
+ st.write(f"**{category.capitalize()}**")
80
+ cols = st.columns(3)
81
+ for i in range(1, 4):
82
+ with cols[i-1]:
83
+ img_path = f'./visualization/{category} ({i}).jpg'
84
+ st.image(img_path, caption=f'{category.capitalize()} ({i})', use_column_width=True)
85
+ st.markdown("---") # Add a horizontal line after each category
86
 
87
+ # Entry point of the script
88
  if __name__ == "__main__":
89
  run()
visualization/cardboard (1).jpg ADDED
visualization/cardboard (2).jpg ADDED
visualization/cardboard (3).jpg ADDED
visualization/food_organics (1).jpg ADDED
visualization/food_organics (2).jpg ADDED
visualization/food_organics (3).jpg ADDED
visualization/glass (1).jpg ADDED
visualization/glass (2).jpg ADDED
visualization/glass (3).jpg ADDED
visualization/metal (1).jpg ADDED
visualization/metal (2).jpg ADDED
visualization/metal (3).jpg ADDED
visualization/misc (1).jpg ADDED
visualization/misc (2).jpg ADDED
visualization/misc (3).jpg ADDED
visualization/paper (1).jpg ADDED
visualization/paper (2).jpg ADDED
visualization/paper (3).jpg ADDED
visualization/plastic (1).jpg ADDED
visualization/plastic (2).jpg ADDED
visualization/plastic (3).jpg ADDED
visualization/textile (1).jpg ADDED
visualization/textile (2).jpg ADDED
visualization/textile (3).jpg ADDED
visualization/vegetation (1).jpg ADDED
visualization/vegetation (2).jpg ADDED
visualization/vegetation (3).jpg ADDED