# app.py - NeuroSense: The Brain IMDb # FINAL FIXED — NAVIGATION 100% WORKING — UI PERFECT — NO GROWTH — HUGGING FACE READY import os os.environ['TF_ENABLE_ONEDNN_OPTS'] = '0' os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2' import gradio as gr import numpy as np import pandas as pd import plotly.graph_objects as go import plotly.express as px from tensorflow.keras.models import load_model import json from preprocess import preprocess_eeg print("Loading CNN-Gai-GRU model...") model = load_model("cnnGru_fydp.keras", compile=False) print("Model loaded successfully!") CLASSES = ["Focused", "Funny", "Meditation", "Normal", "Sad"] COLORS = ["#00ff88", "#ffaa00", "#aa00ff", "#888888", "#3366ff"] COLOR_MAP = dict(zip(CLASSES, COLORS)) CLASS_TO_IDX = {c: i for i, c in enumerate(CLASSES)} css = """ html, body { min-height: 100vh !important; margin: 0; padding: 0; } .gradio-container { min-height: 100vh !important; margin: 0; padding: 0; overflow: auto; } body {background: linear-gradient(135deg, #0f0c29, #302b63, #24243e); font-family: 'Segoe UI', sans-serif; color: white;} .logo {position: fixed; top: 20px; left: 30px; font-size: 3rem; font-weight: bold; cursor: pointer; z-index: 1000; background: rgba(0,255,255,0.2); padding: 15px 30px; border-radius: 25px; backdrop-filter: blur(15px); box-shadow: 0 8px 32px rgba(0,255,255,0.3); transition: 0.4s;} .logo:hover {transform: scale(1.05);} .sidebar {position: fixed; left: 30px; top: 50%; transform: translateY(-50%); background: rgba(255,255,255,0.08); padding: 22px 14px; border-radius: 22px; backdrop-filter: blur(12px); box-shadow: 0 8px 40px rgba(0,0,0,0.45); z-index: 999;} .sidebar button {display: block; width: 200px; margin: 12px 0; padding: 14px; background: rgba(255,255,255,0.12); border: none; border-radius: 14px; color: white; font-size: 1.05rem; font-weight: 600; cursor: pointer; transition: 0.25s;} .sidebar button:hover {background: #00ffff; color: black; transform: translateX(6px);} .sidebar .active {background: #00ffff !important; color: black !important; font-weight: bold;} #main-content {margin-left: 270px; margin-top: 90px; padding: 28px; max-height: calc(100vh - 140px); overflow-y: auto; box-sizing: border-box;} .card {background: rgba(255,255,255,0.06); padding: 22px; border-radius: 18px; backdrop-filter: blur(10px); margin: 18px 0; box-shadow: 0 10px 30px rgba(0,0,0,0.35);} .current-emotion {font-size: 3.2rem; text-align: center; padding: 28px; border-radius: 20px; background: rgba(0,0,0,0.6); font-weight: bold; text-transform: uppercase; letter-spacing: 2px; animation: pulse 2s infinite;} @keyframes pulse {0% {box-shadow: 0 0 20px rgba(0,255,255,0.5);} 50% {box-shadow: 0 0 40px rgba(0,255,255,0.9);} 100% {box-shadow: 0 0 20px rgba(0,255,255,0.5);}} .plot-container {height: 380px !important; margin: 20px 0;} """ # FINAL JS — NAVIGATION WORKS 100% — NO BLOCKED onclick js = """ """ % (json.dumps(CLASSES), json.dumps(COLOR_MAP)) with gr.Blocks(css=css, js=js, theme=gr.themes.Soft(), title="NeuroSense") as demo: page = gr.State("landing") preds_state = gr.State([]) ts_state = gr.State([]) video_path = gr.State(None) js_data = gr.State(None) gr.HTML("""
The Brain IMDb
") with gr.Column(visible=False, elem_id="page-about"): gr.HTML("FYDP 2025