rachman commited on
Commit
2586595
Β·
verified Β·
1 Parent(s): 0005824

Upload 13 files

Browse files
src/LOGO_AISEE_YOU.png ADDED
src/best.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7ca66d3533818ee2af3df16d17b7085261c7ecdcf4c471078152659d12422f96
3
+ size 6216746
src/prediction.py ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from ultralytics import YOLO
3
+ from PIL import Image
4
+ import numpy as np
5
+ import os
6
+ import matplotlib.pyplot as plt
7
+ import matplotlib.patches as patches
8
+
9
+ model = YOLO("best.pt")
10
+
11
+ label_map = {
12
+ 0: "scissors",
13
+ 1: "unidentified",
14
+ 2: "knife",
15
+ 3: "cutter",
16
+ 4: "swiss knife",
17
+ }
18
+
19
+ def show_prediction(img):
20
+ results = model.predict(source=img, conf=0.25, save=False)
21
+
22
+ if results:
23
+ st.write("Results:")
24
+ for result in results:
25
+ if result.boxes.cls.numel() > 0:
26
+ fig, ax = plt.subplots()
27
+ ax.imshow(img)
28
+
29
+ x1, y1, x2, y2 = result.boxes.xyxy[0]
30
+ rect = patches.Rectangle((x1, y1), x2 - x1, y2 - y1,
31
+ linewidth=1, edgecolor="r", facecolor="none")
32
+ ax.add_patch(rect)
33
+
34
+ ax.text(x1, y1, f"{label_map[int(result.boxes.cls[0])]} {result.boxes.conf[0]:.2f}",
35
+ fontsize=12, color="white", bbox=dict(facecolor="red", alpha=0.5))
36
+ ax.axis("off")
37
+ st.pyplot(fig)
38
+ else:
39
+ st.write("No objects detected.")
40
+
41
+ def run():
42
+ st.title("AI SEE YOU")
43
+
44
+ # Example images
45
+ example_images = ['test1.jpg', 'test2.jpg', 'test3.jpg', 'test4.jpg',
46
+ 'test5.jpg', 'test6.jpg', 'test7.jpg', 'test8.jpg']
47
+ example_path = './visualization'
48
+
49
+ st.subheader("Choose an example image or upload your own:")
50
+
51
+ if 'selected_image_path' not in st.session_state:
52
+ st.session_state.selected_image_path = None
53
+ st.session_state.uploaded_image = None
54
+
55
+ # Display example images
56
+ cols = st.columns(4)
57
+ for i, img_name in enumerate(example_images):
58
+ with cols[i % 4]:
59
+ img_path = os.path.join(example_path, img_name)
60
+ st.image(img_path, width=100, caption=f'Example {i+1}')
61
+ if st.button(f"Example {i+1}", key=f"example_{i}"):
62
+ st.session_state.selected_image_path = img_path
63
+ st.session_state.uploaded_image = None # Reset uploaded image
64
+
65
+ # File uploader
66
+ file = st.file_uploader("Upload an image", type=["jpg", "jpeg", "png"])
67
+ if file is not None:
68
+ st.session_state.uploaded_image = file
69
+ st.session_state.selected_image_path = None # Reset example image
70
+
71
+ image = None
72
+
73
+ if st.session_state.uploaded_image:
74
+ image = Image.open(st.session_state.uploaded_image).convert("RGB")
75
+ st.subheader("Uploaded Image")
76
+ st.image(image, caption="Uploaded Image")
77
+ show_prediction(image)
78
+
79
+ elif st.session_state.selected_image_path:
80
+ image = Image.open(st.session_state.selected_image_path).convert("RGB")
81
+ st.subheader("Selected Example Image")
82
+ st.image(image, caption="Selected Example Image")
83
+ show_prediction(image)
84
+
85
+ # if __name__ == "__main__":
86
+ # app()
src/requirements.txt ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ streamlit
2
+ pandas
3
+ altair
4
+ numpy
5
+ Pillow
6
+ opencv-python-headless
7
+ ultralytics
src/streamlit_app.py CHANGED
@@ -1,40 +1,116 @@
1
- import altair as alt
2
- import numpy as np
3
- import pandas as pd
4
  import streamlit as st
 
 
5
 
6
- """
7
- # Welcome to Streamlit!
8
-
9
- Edit `/streamlit_app.py` to customize this app to your heart's desire :heart:.
10
- If you have any questions, checkout our [documentation](https://docs.streamlit.io) and [community
11
- forums](https://discuss.streamlit.io).
12
-
13
- In the meantime, below is an example of what you can do with just a few lines of code:
14
- """
15
-
16
- num_points = st.slider("Number of points in spiral", 1, 10000, 1100)
17
- num_turns = st.slider("Number of turns in spiral", 1, 300, 31)
18
-
19
- indices = np.linspace(0, 1, num_points)
20
- theta = 2 * np.pi * num_turns * indices
21
- radius = indices
22
-
23
- x = radius * np.cos(theta)
24
- y = radius * np.sin(theta)
25
-
26
- df = pd.DataFrame({
27
- "x": x,
28
- "y": y,
29
- "idx": indices,
30
- "rand": np.random.randn(num_points),
31
- })
32
-
33
- st.altair_chart(alt.Chart(df, height=700, width=700)
34
- .mark_point(filled=True)
35
- .encode(
36
- x=alt.X("x", axis=None),
37
- y=alt.Y("y", axis=None),
38
- color=alt.Color("idx", legend=None, scale=alt.Scale()),
39
- size=alt.Size("rand", legend=None, scale=alt.Scale(range=[1, 150])),
40
- ))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import streamlit as st
2
+ import prediction
3
+ # import eda # Uncomment if you have eda.py
4
 
5
+ # Set page configuration
6
+ st.set_page_config(
7
+ page_title="AISeeYou",
8
+ page_icon="LOGO_AISEE_YOU.PNG", # Menggunakan logo sebagai icon tab
9
+ layout="wide", # Centered layout
10
+ initial_sidebar_state="expanded"
11
+ )
12
+
13
+ # Inisialisasi session state untuk fun fact
14
+ if 'fun_fact_index' not in st.session_state:
15
+ st.session_state['fun_fact_index'] = 0
16
+
17
+ def main():
18
+ # Sidebar
19
+ st.sidebar.image("LOGO_AISEE_YOU.PNG", width=150)
20
+ st.sidebar.title("Navigation")
21
+ page = st.sidebar.radio("Go to", ["🏠 Home", "πŸ” Prediction"])
22
+
23
+ if page == "🏠 Home":
24
+ # Sidebar Info
25
+ # st.sidebar.markdown("---")
26
+ # st.sidebar.subheader("πŸ“Š About the Model")
27
+ # accuracy = 0.82
28
+ # st.sidebar.write("🎯 Model Accuracy:")
29
+ # st.sidebar.progress(accuracy)
30
+ # st.sidebar.write(f"{accuracy:.2%}")
31
+ # st.sidebar.write("**πŸ€” What is Accuracy?**")
32
+ # st.sidebar.write("Accuracy measures how well our model correctly classifies waste items.")
33
+ # st.sidebar.write("**πŸ’‘ What does this mean?**")
34
+ # st.sidebar.write(f"Our model correctly classifies {accuracy:.2%} of waste items, helping improve recycling efficiency.")
35
+
36
+ # st.sidebar.markdown("---")
37
+ # st.sidebar.subheader("♻️ Fun Facts")
38
+ # fun_facts = [
39
+ # "Proper waste classification can increase recycling rates by up to 50%!",
40
+ # "Recycling one aluminum can saves enough energy to run a TV for three hours.",
41
+ # "It takes 450 years for a plastic bottle to decompose in a landfill.",
42
+ # "Glass can be recycled endlessly without losing quality or purity.",
43
+ # "Recycling paper saves 17 trees and 7,000 gallons of water per ton of paper."
44
+ # ]
45
+ # st.sidebar.info(fun_facts[st.session_state['fun_fact_index']])
46
+
47
+ # if st.sidebar.button("Next Fun Fact"):
48
+ # st.session_state['fun_fact_index'] = (st.session_state['fun_fact_index'] + 1) % len(fun_facts)
49
+ # st.rerun()
50
+
51
+ # Main Content - Home
52
+ st.title("Welcome to AI See You Tools")
53
+ st.write("""
54
+ This application provides functionalities for Exploratory Data Analysis and
55
+ Prediction of waste types. Use the navigation pane on the left to
56
+ select the module you wish to utilize.
57
+ """)
58
+
59
+ # Logo di tengah halaman
60
+ col1, col2, col3 = st.columns([1, 2, 1])
61
+ with col2:
62
+ st.image("LOGO_AISEE_YOU.PNG", caption="AISeeYou", width=300)
63
+
64
+ st.markdown("---")
65
+
66
+ # Dataset Info
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
+ Dalam upaya menjaga keselamatan dan keamanan publik, khususnya di tempat-tempat vital seperti bandara,
78
+ terminal, dan gedung pemerintahan, pemeriksaan barang bawaan menjadi langkah penting yang tidak
79
+ bisa diabaikan. Salah satu metode utama yang digunakan adalah pemindaian X-ray terhadap bagasi
80
+ atau tas penumpang untuk mendeteksi adanya benda-benda berbahaya seperti senjata api, pisau, atau alat tajam lainnya.
81
+ Meskipun teknologi pemindaian X-ray telah tersedia secara luas, proses interpretasi citra X-ray masih sangat bergantung
82
+ pada keahlian manusia, yang memiliki keterbatasan dalam hal konsistensi, kecepatan, dan akurasi, terutama ketika
83
+ menghadapi volume penumpang yang tinggi. Dalam konteks ini, penerapan Artificial Intelligence (AI) dan
84
+ Computer Vision dapat menjadi solusi potensial untuk meningkatkan efektivitas sistem keamanan.
85
+ """)
86
+
87
+ # Objective
88
+ st.write("#### 🎯 Objective")
89
+ st.success("""
90
+ Proyek ini bertujuan untuk secara komprehensif mengeksplorasi dan menganalisis
91
+ dataset citra X-ray bagasi yang berisi gambar-gambar hasil pemindaian
92
+ serta anotasi objek-objek berbahaya seperti senjata tajam, bahan peledak,
93
+ dan benda mencurigakan lainnya dengan metrics yang ditentukan adalah recall dan mAP50 mencapai 80%. Tujuan utama dari proyek ini mencakup beberapa
94
+ tahap penting yang saling terkait, yakni:
95
+
96
+ 1. Eksplorasi dan Pemahaman Dataset.
97
+ 2. Analisis Distribusi dan Karakteristik Visual.
98
+ 3. Analisis Visual Interaktif.
99
+ 4. Pengembangan dan Pelatihan Model Deep Learning.
100
+ 5. Evaluasi Performa Model.
101
+ 6. Interpretasi dan Implikasi Praktis.
102
+
103
+ Dengan pendekatan yang sistematis ini, proyek diharapkan mampu menghasilkan pemahaman
104
+ yang mendalam terhadap data serta mengembangkan early prototype model yang dapat mendeteksi
105
+ objek berbahaya. Prototipe ini diharapkan dapat menjadi langkah awal dalam kontribusi
106
+ terhadap sistem keamanan publik yang lebih canggih dan responsif.
107
+ """)
108
+
109
+ elif page == "πŸ” Prediction":
110
+ prediction.run()
111
+
112
+ # elif page == "πŸ“Š EDA":
113
+ # eda.run()
114
+
115
+ if __name__ == "__main__":
116
+ main()
src/visualization/test1.jpg ADDED
src/visualization/test2.jpg ADDED
src/visualization/test3.jpg ADDED
src/visualization/test4.jpg ADDED
src/visualization/test5.jpg ADDED
src/visualization/test6.jpg ADDED
src/visualization/test7.jpg ADDED
src/visualization/test8.jpg ADDED