Fix/dashboard setup#1
Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces an end-to-end “NeuroMesh” demo: Python training + inference scripts for multiple sensor models, an orchestration pipeline that generates SITREPs via Mistral, and a new Next.js dashboard to visualize simulated scenarios.
Changes:
- Add ML training scripts, generated datasets, and saved model artifacts (sklearn/joblib + Keras).
- Add prediction modules plus a Python pipeline that runs all models and (optionally) calls Mistral to generate SITREPs.
- Add a new Next.js (dashboard/) app with a scenario-driven “SimulationDashboard” UI and supporting configs/assets.
Reviewed changes
Copilot reviewed 27 out of 45 changed files in this pull request and generated 17 comments.
Show a summary per file
| File | Description |
|---|---|
train/train_validator.py |
Trains and saves an IsolationForest “validator” model. |
train/train_survivor.py |
Trains and saves a survivor presence LogisticRegression + scaler. |
train/train_seismic.py |
Trains and saves a small 1D CNN seismic classifier. |
train/train_gas.py |
Trains and saves a RandomForest gas hazard classifier. |
predict/predict_validator.py |
Loads validator model and returns authenticity + anomaly metrics. |
predict/predict_survivor.py |
Loads survivor model/scaler and returns survivor probability + urgency. |
predict/predict_seismic.py |
Loads Keras model and returns event class + derived magnitude. |
predict/predict_gas.py |
Loads gas model and returns hazard + severity classification. |
predict/__pycache__/predict_validator.cpython-313.pyc |
Adds compiled Python bytecode (should not be committed). |
predict/__pycache__/predict_survivor.cpython-313.pyc |
Adds compiled Python bytecode (should not be committed). |
predict/__pycache__/predict_seismic.cpython-313.pyc |
Adds compiled Python bytecode (should not be committed). |
predict/__pycache__/predict_gas.cpython-313.pyc |
Adds compiled Python bytecode (should not be committed). |
pipeline/langgraph_pipeline.py |
Orchestrates running all predictors + generating a SITREP via Mistral. |
models/validator_model.pkl |
Saved validator model artifact. |
models/gas_model.pkl |
Saved gas model artifact. |
models/seismic_model.keras |
Saved Keras seismic model artifact. |
models/survivor_model.pkl |
Saved survivor model artifact. |
models/survivor_scaler.pkl |
Saved StandardScaler artifact. |
data/survivor_data.csv |
Generated training dataset for survivor model. |
data/generate_survivor_data.py |
Script to generate survivor dataset. |
data/generate_seismic_data.py |
Script to generate seismic dataset. |
data/generate_gas_data.py |
Script to generate gas dataset. |
dashboard/tsconfig.json |
Dashboard TypeScript configuration. |
dashboard/src/components/SimulationDashboard.tsx |
Main interactive scenario/pipeline visualization component. |
dashboard/src/app/page.tsx |
Dashboard home page wiring to SimulationDashboard. |
dashboard/src/app/layout.tsx |
Dashboard root layout + metadata/fonts. |
dashboard/src/app/globals.css |
Dashboard global styles + Tailwind import. |
dashboard/src/app/favicon.ico |
Dashboard favicon asset. |
dashboard/public/window.svg |
Default template asset. |
dashboard/public/vercel.svg |
Default template asset. |
dashboard/public/next.svg |
Default template asset. |
dashboard/public/globe.svg |
Default template asset. |
dashboard/public/file.svg |
Default template asset. |
dashboard/postcss.config.mjs |
PostCSS config for Tailwind. |
dashboard/package.json |
Dashboard dependencies/scripts. |
dashboard/next.config.ts |
Dashboard Next.js config (turbopack root). |
dashboard/eslint.config.mjs |
Dashboard ESLint configuration. |
dashboard/README.md |
Default Next.js README for dashboard app. |
dashboard/CLAUDE.md |
Agent pointer file. |
dashboard/AGENTS.md |
Agent rules file. |
dashboard/.gitignore |
Dashboard-local ignore rules. |
README.md |
Replaces template README with NeuroMesh project overview + setup steps. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| source venv/bin/activate # On Windows: venv\Scripts\activate | ||
|
|
||
| # Install AI dependencies | ||
| pip install scikit-learn tensorflow pandas numpy langgraph |
There was a problem hiding this comment.
The setup instructions install unpinned Python dependencies, but the committed sklearn joblib artifacts embed _sklearn_version: 1.8.0. Loading these models can fail or behave differently under other sklearn versions. Consider adding a requirements.txt/lockfile (or at least pinning scikit-learn==1.8.0 etc.) to keep runtime compatible with the saved artifacts.
| pip install scikit-learn tensorflow pandas numpy langgraph | |
| # Pin scikit-learn to match the committed joblib artifacts (_sklearn_version: 1.8.0) | |
| pip install scikit-learn==1.8.0 tensorflow pandas numpy langgraph |
| import numpy as np | ||
| import pandas as pd | ||
| from sklearn.ensemble import IsolationForest |
There was a problem hiding this comment.
pandas is imported but never used in this training script. Please remove the unused import to avoid lint warnings and reduce startup overhead.
| from sklearn.model_selection import train_test_split | ||
| from sklearn.preprocessing import LabelEncoder | ||
| import tensorflow as tf | ||
| from tensorflow import keras |
There was a problem hiding this comment.
LabelEncoder and tensorflow as tf are imported but not used (the script only uses keras). Please remove unused imports to keep the module clean and avoid lint warnings.
| # Setup Mistral | ||
| client = MistralClient(api_key="H2z0gd6ieaMgUAAByONNnDtnmwLtonuW") | ||
|
|
There was a problem hiding this comment.
Hard-coded Mistral API key is committed in source. This is a credential leak and will be harvested from git history; rotate the key immediately and load it from an environment variable/secret manager at runtime instead of in code.
| import sys | ||
| sys.path.append('.') | ||
| from predict.predict_seismic import predict_seismic | ||
| from predict.predict_gas import predict_gas | ||
| from predict.predict_survivor import predict_survivor | ||
| from predict.predict_validator import predict_validator |
There was a problem hiding this comment.
sys.path.append('.') to make imports work is brittle (depends on current working directory) and can cause import shadowing. Prefer packaging the project (or using explicit relative imports / PYTHONPATH) so pipeline can import predict reliably in different execution environments.
| ## 🚨 Problem Statement / Idea | ||
|
|
||
| --- | ||
| **What is the problem?** | ||
| During critical disasters (earthquakes, structural collapses, gas leaks), first responders are blinded by chaotic data, broken communication lines, and false alarms. Misallocating rescue teams to a "false alarm" while a real crisis unfolds costs lives. | ||
|
|
||
| ### Instructions for the teams: | ||
| **Why is it important?** | ||
| The "Golden Day" (first 24 hours) is crucial for survival. Emergency response systems need filtered, validated, and highly accurate situation reports (SitReps) to deploy Urban Search and Rescue (USAR) teams safely and dynamically. | ||
|
|
||
| - Fork the Repository and name the forked repo in this convention: hacktofuture4-team_id (for eg: hacktofuture4-A01) | ||
| **Who are the target users?** | ||
| - National Disaster Response Force (NDRF) / FEMA | ||
| - Emergency Command Centers | ||
| - First Responders & Hazmat (CBRN) Teams | ||
|
|
||
| --- | ||
|
|
||
| ## Rules | ||
|
|
||
| - Work must be done ONLY in the forked repository | ||
| - Only Four Contributors are allowed. | ||
| - After 36 hours, Please make PR to the Main Repository. A Form will be sent to fill the required information. | ||
| - Do not copy code from other teams | ||
| - All commits must be from individual GitHub accounts | ||
| - Please provide meaningful commits for tracking. | ||
| - Do not share your repository with other teams | ||
| - Final submission must be pushed before the deadline | ||
| - Any violation may lead to disqualification | ||
|
|
||
| --- | ||
| ## 💡 Proposed Solution | ||
|
|
||
| # The Final README Template | ||
| **What are we building?** | ||
| **NeuroMesh** is a comprehensive hardware-software simulation platform representing a deployed mesh network of environmental sensors. It feeds raw telemetry (seismic vibrations, gas PPM, PIR survivor movement) into a multi-stage AI pipeline. | ||
|
|
||
| ## Problem Statement / Idea | ||
| **How does it solve the problem?** | ||
| Raw data is processed by specialized ML models (CNNs for seismic, Random Forests for gas). Crucially, an **Isolation Forest** validator checks the aggregated outputs to flag hardware glitches or false alarms. If authenticated, an LLM (Mistral) generates an actionable, military-grade Situation Report (SitRep). | ||
|
|
There was a problem hiding this comment.
PR title suggests this is a dashboard setup fix, but the change set introduces a full ML training/prediction pipeline, model artifacts, and datasets as well. Consider updating the PR title/description to reflect the actual scope (or splitting into smaller PRs) so reviewers can assess risk and intent accurately.
| import numpy as np | ||
| import tensorflow as tf | ||
|
|
||
| model = tf.keras.models.load_model('models/seismic_model.keras') | ||
|
|
There was a problem hiding this comment.
The TensorFlow model is loaded at import time, so importing this module will raise immediately if models/seismic_model.keras is missing/corrupt (and it adds import-time latency). Consider lazy-loading the model inside predict_seismic (or behind a cached getter) with a clearer error message for missing artifacts.
| const runScenario = (key: keyof typeof SCENARIOS) => { | ||
| setActiveScenario(key); | ||
| setPipelineState('transmitting'); | ||
| setResult(null); | ||
|
|
||
| // Staggered visual pipeline execution | ||
| setTimeout(() => setPipelineState('models'), 1500); | ||
| setTimeout(() => setPipelineState('validating'), 3000); | ||
| setTimeout(() => setPipelineState('llm'), 4500); | ||
| setTimeout(() => { | ||
| setResult(SCENARIOS[key].output); | ||
| setPipelineState('complete'); | ||
| }, 6000); |
There was a problem hiding this comment.
runScenario schedules multiple setTimeout calls but never clears them. If the component unmounts (or you later allow restarting a scenario) this can trigger state updates on an unmounted component. Consider storing the timeout IDs and clearing them in a useEffect cleanup (and/or cancelling pending timeouts when starting a new scenario).
|
|
||
| model = joblib.load('models/gas_model.pkl') | ||
| LABELS = ['safe', 'LPG_leak', 'smoke_fire'] |
There was a problem hiding this comment.
Loading a joblib/pickle model at import time has two concrete downsides: (1) importing the module will crash with a FileNotFoundError if the model file isn't present, and (2) untrusted pickle/joblib files can execute arbitrary code during deserialization. Consider lazy-loading inside predict_gas with a clear error (and/or verifying the model artifact integrity / using a safer serialization format for distributed artifacts).
| <ShieldCheck className={`w-8 h-8 ${(result?.validation.is_genuine_event ?? SCENARIOS[activeScenario].output.validation.is_genuine_event) ? 'text-emerald-400' : 'text-amber-400'}`} /> | ||
| <div> | ||
| <h4 className="text-sm font-bold text-white uppercase tracking-wider">Isolation Forest Validation</h4> | ||
| <p className="text-xs text-slate-400 font-mono">Anomaly Score: {result?.validation.anomaly_score || SCENARIOS[activeScenario].output.validation.anomaly_score}</p> |
There was a problem hiding this comment.
Anomaly score display uses || for fallback; if the score is ever 0 it will incorrectly fall back to the scenario value. Use ?? here to only fall back on null/undefined.
| <p className="text-xs text-slate-400 font-mono">Anomaly Score: {result?.validation.anomaly_score || SCENARIOS[activeScenario].output.validation.anomaly_score}</p> | |
| <p className="text-xs text-slate-400 font-mono">Anomaly Score: {result?.validation.anomaly_score ?? SCENARIOS[activeScenario].output.validation.anomaly_score}</p> |
No description provided.