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"""

{label}

{val}

""", 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"""
{icon}

{title}

{desc}

""", 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( """

โšก

YOLOv8s

Ultralytics

""", 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'
' f'
' f'

COCO-25 Subset

' f'{rows_html}
', 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'''

๐Ÿ› ๏ธ Tech Stack

{rows_html}
''', 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)