import streamlit as st
import os
"""
# Welcome to Streamlit!
Edit `/streamlit_app.py` to customize this app to your heart's desire :heart:.
If you have any questions, checkout our [documentation](https://docs.streamlit.io) and [community
forums](https://discuss.streamlit.io).
In the meantime, below is an example of what you can do with just a few lines of code:
"""
# โ
MUST be the very first Streamlit call
st.set_page_config(
page_title="SmartVision",
layout="wide",
page_icon="๐๏ธ"
)
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
# HERO WITH IMAGE
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
st.markdown(
"""
""",
unsafe_allow_html=True,
)
# โ
FIX 1: Use forward slash (works on Linux/Mac/Windows)
# image_path = "models/smartvision.png"
import os
APP_ROOT = "/app"
image_path = os.path.join(APP_ROOT, "models", "smartvision.png")
# โ
FIX 2: Check if file exists before loading to give a clear error
if os.path.exists(image_path):
st.image(image_path, use_container_width=True)
else:
st.warning(f"โ ๏ธ Image not found at `{image_path}`. Please ensure the file is committed to your repository.")
st.markdown(
"""
Unified Image Classification & Object Detection Platform
25-Class COCO ยท YOLOv8 ยท VGG16 ยท ResNet50 ยท MobileNetV2 ยท EfficientNetB0
""",
unsafe_allow_html=True,
)
st.info("๐ Use the **sidebar** to navigate between pages.")
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
# SECTION 1 โ TOP STATS
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
st.markdown("### ๐ Platform Overview")
c1, c2, c3, c4, c5 = st.columns(5)
stats = [
("๐ฏ Classes", "25", "#2ecc71"),
("๐ง CNN Models", "4", "#3498db"),
("๐ Detection", "YOLOv8s", "#f39c12"),
("๐ฆ Dataset", "COCO", "#9b59b6"),
("โ๏ธ Deployment", "HF Spaces", "#1abc9c"),
]
for col, (label, val, color) in zip([c1, c2, c3, c4, c5], stats):
with col:
st.markdown(
f"""""",
unsafe_allow_html=True,
)
st.divider()
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
# SECTION 2 โ KEY FEATURES
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
st.markdown("### ๐ Key Features")
feat_col1, feat_col2 = st.columns(2)
features_left = [
("๐ผ๏ธ", "Single-object image classification", "Upload any image โ all 4 CNNs classify it simultaneously with Top-5 predictions."),
("๐ฆ", "Multi-object detection with bounding boxes","YOLOv8 detects and localises multiple objects in a single frame."),
("๐จ", "Color-coded per-class visualisation", "Each of 25 classes has a unique bounding box color for instant recognition."),
]
features_right = [
("๐", "Interactive performance dashboard", "Live charts, confusion matrices, training curves, and per-class mAP breakdown."),
("๐ท", "Live webcam detection", "Real-time YOLOv8 inference on webcam feed with FPS overlay (local only)."),
]
for col, feats in zip([feat_col1, feat_col2], [features_left, features_right]):
with col:
for icon, title, desc in feats:
st.markdown(
f"""""",
unsafe_allow_html=True,
)
st.divider()
# =====================================================
# QUICK NAVIGATION BUTTONS
# =====================================================
st.header("๐ Explore Features")
col1, col2 = st.columns(2)
with col1:
if st.button("๐ผ๏ธ Image Classification", use_container_width=True):
st.switch_page("pages/image_classification.py")
if st.button("๐ CNN Performance", use_container_width=True):
st.switch_page("pages/model_performance.py")
with col2:
if st.button("๐ Object Detection", use_container_width=True):
st.switch_page("pages/yolo_object_detection.py")
if st.button("๐ YOLO Performance", use_container_width=True):
st.switch_page("pages/yolo_performance.py")
st.divider()
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
# SECTION 3 โ MODELS USED
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
st.markdown("### ๐ค Models Used")
# โโ YOLOv8 โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
st.markdown("#### ๐ Object Detection")
yolo_col, yolo_info = st.columns([1, 3])
with yolo_col:
st.markdown(
"""""",
unsafe_allow_html=True,
)
with yolo_info:
chips = [
("ARCHITECTURE", "YOLOv8 Small (YOLOv8s)"),
("PRETRAINED ON", "COCO (80 classes)"),
("FINE-TUNED ON", "25-Class COCO Subset"),
("EPOCHS", "50"),
("IMAGE SIZE", "640 ร 640"),
("mAP@0.5", "0.893"),
("PRECISION", "95.1%"),
("RECALL", "87.7%"),
("INFERENCE", "~6.7 ms ยท ~120 FPS"),
]
chips_html = "".join(
f''
f'{k}'
f'{v}'
for k, v in chips
)
st.markdown(
f"""
{chips_html}
YOLOv8s is Ultralytics' small variant โ optimised for the best balance between
accuracy and inference speed. Fine-tuned with mosaic augmentation,
auto-optimizer (AdamW), and AMP mixed precision.
""",
unsafe_allow_html=True,
)
st.markdown("
", unsafe_allow_html=True)
# โโ CNN Models โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
st.markdown("#### ๐ง Image Classification โ CNN Models")
CNN_MODELS = [
{"name": "EfficientNetB0", "icon": "๐จ", "color": "#f39c12", "highlight": "Best Accuracy"},
{"name": "ResNet50", "icon": "๐ฅ", "color": "#e74c3c", "highlight": "Best All-Rounder"},
{"name": "MobileNetV2", "icon": "๐ฉ", "color": "#2ecc71", "highlight": "Fastest Inference"},
{"name": "VGG16", "icon": "๐ฆ", "color": "#3498db", "highlight": "Reliable Baseline"},
]
for model in CNN_MODELS:
st.markdown(
f"""
{model['icon']}
{model['name']}
{model['highlight']}
""",
unsafe_allow_html=True
)
st.divider()
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
# SECTION 4 โ DATASET + CLASSES
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
st.markdown("### ๐ฆ Dataset")
d1, d2 = st.columns([1, 2])
with d1:
dataset_rows = [
("Total Images", "2,500"),
("Images / Class", "100"),
("Train Split", "70% ยท 1,750 images"),
("Val Split", "15% ยท 375 images"),
("Test Split", "15% ยท 375 images"),
("Image Size", "224 ร 224 px"),
("Annotation", "COCO Bounding Boxes"),
("Source", "Hugging Face (streaming)"),
]
rows_html = "".join(
f''
f'{k}'
f'{v}
'
for k, v in dataset_rows
)
st.markdown(
f'',
unsafe_allow_html=True,
)
with d2:
st.markdown("**25 Supported Classes:**")
CLASS_NAMES = [
'person','bicycle','car','motorcycle','airplane','bus','train','truck',
'traffic light','stop sign','bench','bird','cat','dog','horse','cow',
'elephant','bottle','cup','bowl','pizza','cake','chair','couch','potted plant',
]
ICONS = {
'person':'๐ง','bicycle':'๐ฒ','car':'๐','motorcycle':'๐๏ธ','airplane':'โ๏ธ',
'bus':'๐','train':'๐','truck':'๐','traffic light':'๐ฆ','stop sign':'๐',
'bench':'๐ช','bird':'๐ฆ','cat':'๐ฑ','dog':'๐ถ','horse':'๐ด','cow':'๐ฎ',
'elephant':'๐','bottle':'๐ถ','cup':'โ','bowl':'๐ฅฃ','pizza':'๐',
'cake':'๐','chair':'๐ช','couch':'๐๏ธ','potted plant':'๐ชด',
}
badges = " ".join(
f''
f'{ICONS.get(c,"โข")} {c}'
for c in CLASS_NAMES
)
st.markdown(f'{badges}
', unsafe_allow_html=True)
st.divider()
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
# SECTION 5 โ BUSINESS APPLICATIONS
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
st.markdown("### ๐ Business Applications")
APPS = [
("๐๏ธ", "Smart Cities & Traffic Management",
"Automated vehicle detection ยท Pedestrian safety monitoring ยท Parking detection ยท Traffic violation detection"),
("๐", "Retail & E-Commerce",
"Product recognition ยท Scan-free checkout ยท Customer behaviour analytics ยท Visual search"),
("๐", "Security & Surveillance",
"Intrusion detection ยท Unattended object alerts ยท Perimeter monitoring ยท Crowd density analysis"),
("๐ฆ", "Wildlife Conservation",
"Species identification ยท Habitat monitoring ยท Poaching prevention ยท Population studies"),
("๐ฅ", "Healthcare",
"PPE compliance verification ยท Equipment tracking ยท Patient fall detection ยท Hygiene monitoring"),
("๐ ", "Smart Home & IoT",
"Home automation ยท Security alerts ยท Pet activity tracking ยท Energy usage detection"),
("๐พ", "Agriculture",
"Livestock monitoring ยท Pest detection ยท Equipment tracking ยท Harvest readiness detection"),
("๐ฆ", "Logistics & Warehousing",
"Package sorting ยท Inventory tracking ยท Quality control ยท Loading bay monitoring"),
]
for icon, title, description in APPS:
st.markdown(
f"""
{icon}
{title}:
{description}
""",
unsafe_allow_html=True,
)
st.divider()
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
# SECTION 6 โ TECH STACK + RESULTS
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
st.markdown("### ๐ ๏ธ Tech Stack & Project Info")
tech_col, dev_col = st.columns([1, 1])
with tech_col:
TECH = [
("๐", "Python 3.10", "Core programming language"),
("๐ค", "TensorFlow / Keras", "CNN training & inference"),
("โก", "Ultralytics YOLOv8", "Object detection & fine-tuning"),
("๐๏ธ", "OpenCV", "Image processing & annotation"),
("๐", "Streamlit", "Interactive web app framework"),
("๐ค", "Hugging Face Spaces", "Cloud deployment platform"),
("๐", "Matplotlib / Seaborn", "Visualisations"),
("๐ข", "NumPy / Pandas", "Data processing"),
("๐งช", "Scikit-learn", "Evaluation metrics"),
]
rows_html = "".join(
f''
f'{icon}'
f'{name}'
f'{desc}
'
for icon, name, desc in TECH
)
st.markdown(
f'''''',
unsafe_allow_html=True,
)
with dev_col:
st.markdown("""
๐ Model Scope & Results
Image Classification (Transfer Learning)
Object Detection (YOLOv8 Fine-tuning)
Evaluation โ Accuracy ยท mAP@0.5 ยท Precision ยท Recall ยท F1
CNN Result โ 92% (EfficientNetB0) โ
YOLO Result โ mAP@0.5 = 0.893 โ
""", unsafe_allow_html=True)