Spaces:
Sleeping
Sleeping
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() |