File size: 2,220 Bytes
5bb140d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9c23cdc
5bb140d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import streamlit as st
import matplotlib.pyplot as plt
from PIL import Image
import os

def run():
    # Title
    st.title('Safe and Unsafe Working Condition')

    # Sub Header
    st.subheader('Exploratory Data Analysis (EDA) of dataset')

    # Image
    image = Image.open('./src/image11.jpg')
    st.image(image)

    # Data
    st.write('##### Dataset Overview')

    main_path = './src/Worksite-Safety-Monitoring-Dataset/'
    train_path = os.path.join(main_path, 'train')
    val_path = os.path.join(main_path, 'valid')
    test_path = os.path.join(main_path, 'test')

    def plot_images(path):
        labels = sorted(os.listdir(path))
        figures = []
        for label in labels:
            folder_path = os.path.join(path, label)
            images = os.listdir(folder_path)
            images = images[:5]
            fig, axes = plt.subplots(1, len(images), figsize=(50, 50))
            if len(images) == 1:
                axes = [axes]
            for idx, img_file in enumerate(images):
                img = plt.imread(os.path.join(folder_path, img_file))
                axes[idx].imshow(img)
                axes[idx].axis("off")
                axes[idx].set_title(label, fontsize=50, fontweight='bold')
            plt.tight_layout()
            figures.append(fig)
        return figures
    
    # Train
    st.write('##### Train')
    figs_train = plot_images(train_path)
    for fig in figs_train:
        st.pyplot(fig)

    # Validation
    st.write('##### Validation')
    figs_val = plot_images(val_path)
    for fig in figs_val:
        st.pyplot(fig)

    # Test
    st.write('##### Test')
    figs_test = plot_images(test_path)
    for fig in figs_test:
        st.pyplot(fig)

    st.markdown("""
                ##### Exploration:

                This project aims to classify construction site conditions into **safe** or **unsafe** categories using deep learning.

                The model is trained using a MobileNetV2 backbone and achieves high performance in real-world safety image classification.

                The tool supports maintenance planning, reduces on-site risks, and improves safety compliance.
                """)

if __name__ == '__main__':
    run()