Soumya2022gkn-GitHb/Real-Time-Flight-Instability-Detection-using-PyTorch
GitHub: Soumya2022gkn-GitHb/Real-Time-Flight-Instability-Detection-using-PyTorch
基于 PyTorch 和 Isolation Forest 的混合异常检测平台,用于实时分析飞行遥测数据并快速识别不稳定飞行行为。
Stars: 0 | Forks: 0
# ✈️ 航班异常 AI 核心
模块化航空航天遥测智能平台,用于实时飞行异常检测,使用:
- PyTorch Autoencoders
- Isolation Forest
- Feature Engineering Pipelines
- Real-Time Inference
- Streamlit Dashboards
- Telemetry Monitoring
该系统从遥测流中检测不稳定的飞行行为,并将异常排查时间从数小时缩短至数分钟。
# 🚀 项目架构
```
Flight Telemetry
↓
Data Generation
↓
Feature Engineering
↓
Normalization
↓
Isolation Forest
↓
PyTorch Autoencoder
↓
Hybrid Anomaly Scoring
↓
Real-Time Inference
↓
Telemetry Monitoring Dashboard
```
# 📂 项目结构
```
flight_anomaly_ai_core/
│
├── data_generation/
│ │
│ ├── generate_flight_data.py
│ ├── inject_anomalies.py
│ ├── simulate_instability.py
│ └── generate_telemetry_stream.py
│
├── dataset/
│ │
│ ├── flight_telemetry.csv
│ ├── processed_features.csv
│ └── anomaly_labels.csv
│
├── feature_engineering/
│ │
│ ├── rolling_statistics.py
│ ├── altitude_features.py
│ ├── velocity_features.py
│ ├── oscillation_detection.py
│ └── normalize_features.py
│
├── training/
│ │
│ ├── train_isolation_forest.py
│ ├── train_autoencoder.py
│ ├── evaluate_model.py
│ └── anomaly_scoring.py
│
├── models/
│ │
│ ├── isolation_forest.pkl
│ ├── autoencoder.pth
│ └── scaler.pkl
│
├── inference/
│ │
│ ├── predict_anomalies.py
│ ├── realtime_inference.py
│ └── telemetry_monitor.py
│
├── visualization/
│ │
│ ├── altitude_anomalies.png
│ ├── velocity_spikes.png
│ ├── oscillation_detection.png
│ └── anomaly_dashboard.png
│
├── app/
│ │
│ ├── app.py
│ ├── dashboard.py
│ └── telemetry_viewer.py
│
├── utils/
│ │
│ ├── logger.py
│ ├── helpers.py
│ └── config.py
│
├── tests/
│ │
│ ├── test_feature_engineering.py
│ ├── test_training.py
│ └── test_inference.py
│
├── requirements.txt
├── README.md
├── .gitignore
└── main.py
```
# ⚙️ 核心功能
## ✅ 合成飞行遥测数据生成
生成逼真的遥测数据:
- Altitude
- Velocity
- Pitch
- Roll
- Yaw
带有以下特征:
- turbulence、
- instability、
- oscillations、
- sudden drops、
- 以及 anomalies。
# 📊 遥测信号
## 海拔高度 vs 时间
```
Altitude
^
|
| /\ /\ /\
| / \______/ \____/ \
|
+----------------------------------> Time
```
## 速度尖峰
```
Velocity
^
|
| /\ /\ /\
|_____/ \____/ \____/ \____
|
+----------------------------------> Time
```
## 俯仰角振荡
```
Pitch
^
|
| ~~~~ ~~~~ ~~~~ ~~~~
|
+----------------------------------> Time
```
# 🧠 ML 模型
## 1. Isolation Forest
经典的异常检测模型:
```
Normal Data → Dense Regions
Anomalies → Sparse Regions
```
用于:
- outlier detection、
- 遥测不稳定性识别。
## 2. PyTorch Autoencoder
深度学习重建模型:
```
Input Telemetry
↓
Encoder
↓
Latent Representation
↓
Decoder
↓
Reconstructed Telemetry
```
高重建误差 ⇒ anomaly。
# 📉 Autoencoder 损失曲线
```
Loss
^
|\
| \
| \
| \
| \_____
|
+------------------> Epochs
```
# 🔥 混合异常评分
综合得分:
```
Final Score =
0.5 × Autoencoder Score
+
0.5 × Isolation Forest Score
```
# 📡 实时推理 Pipeline
```
Telemetry Stream
↓
Feature Extraction
↓
Autoencoder Inference
↓
Isolation Forest Inference
↓
Combined Scoring
↓
Anomaly Alert
```
# 🚨 实时监控
该系统支持:
- 实时遥测流、
- 实时异常检测、
- 异常警报生成、
- 遥测仪表盘、
- 监控控制台。
# 🖥️ Streamlit 仪表盘
交互式仪表盘功能:
✅ 遥测可视化
✅ 异常标记
✅ 异常分数时间线
✅ 高风险事件表
✅ 实时监控
✅ 信号分布
运行:
```
streamlit run app/dashboard.py
```
# 📈 混淆矩阵
```
Predicted
Normal Anomaly
True Normal TN FP
True Anomaly FN TP
```
自动生成:
```
visualization/confusion_matrix.png
```
# 🧪 测试 Pipelines
本项目包含:
```
tests/
├── test_feature_engineering.py
├── test_training.py
└── test_inference.py
```
验证:
- 数据集、
- 特征、
- 模型、
- 预测、
- inference pipelines。
# ⚡ 安装
## 克隆仓库
```
git clone
cd flight_anomaly_ai_core
```
## 创建虚拟环境
### Windows
```
python -m venv venv
venv\Scripts\activate
```
# 📦 安装依赖
```
pip install -r requirements.txt
```
# ▶️ 运行完整 Pipeline
```
python main.py
```
# 📊 启动仪表盘
```
streamlit run app/dashboard.py
```
# 🧠 ML Pipeline 流程
```
Generate Data
↓
Inject Anomalies
↓
Feature Engineering
↓
Normalize Features
↓
Train Isolation Forest
↓
Train Autoencoder
↓
Evaluate Models
↓
Predict Anomalies
↓
Real-Time Inference
↓
Dashboard Monitoring
```
# 📁 生成的输出
## 数据集
```
dataset/
├── flight_telemetry.csv
├── processed_features.csv
├── normalized_features.csv
├── predicted_anomalies.csv
└── anomaly_scores.csv
```
## 模型
```
models/
├── isolation_forest.pkl
├── autoencoder.pth
└── scaler.pkl
```
## 可视化
```
visualization/
├── confusion_matrix.png
├── altitude_anomalies.png
├── velocity_spikes.png
└── anomaly_dashboard.png
```
# 🔬 示例用例
## 航空航天初创公司
- 飞行测试监控、
- 遥测异常检测、
- 不稳定性诊断。
## UAV / 无人机系统
- 自主监控、
- 飞行安全分析、
- 实时遥测智能。
## AI + 航空航天研究
- 异常检测研究、
- 遥测 ML pipelines、
- 流式 inference 系统。
# 🛠️ 技术栈
| 组件 | 技术 |
|---|---|
| ML | PyTorch |
| 经典 ML | Scikit-learn |
| 仪表盘 | Streamlit |
| 数据处理 | Pandas |
| 数值计算 | NumPy |
| 可视化 | Matplotlib |
| 模型序列化 | Joblib |
# 📌 未来改进
## 计划功能
- LSTM 遥测模型
- 基于 Transformer 的异常检测
- Kafka 遥测流
- FastAPI inference server
- Docker 部署
- Kubernetes 扩展
- AWS 部署
- 基于 LLM 的异常解释
# 📡 示例实时警报
```
{
"timestamp": 421,
"combined_score": 0.91,
"prediction": "anomaly"
}
```
# 🧠 示例 LLM 解释层
```
"Sudden altitude drop combined with
high pitch oscillation suggests
possible flight instability."
```
# 🏁 最终成果
本项目展示了:
✅ 端到端 ML 系统设计
✅ 航空航天遥测分析
✅ 实时异常检测
✅ PyTorch 深度学习 pipelines
✅ 流式 inference 系统
✅ 生产级 ML 架构
✅ 监控仪表盘
✅ ML 测试工作流
# 👨💻 作者
Flight Telemetry Intelligence Project
使用以下技术构建:
- PyTorch
- Isolation Forest
- Streamlit
- 航空航天遥测 ML pipelines
标签:AIOps, Apex, Kubernetes, PyTorch, Streamlit, 人工智能, 凭据扫描, 孤立森林, 实时推理, 异常检测, 振荡检测, 数据生成, 时间序列分析, 机器学习, 模型训练, 流数据监控, 混合异常评分, 特征工程, 用户模式Hook绕过, 自编码器, 航空安全, 航空航天, 访问控制, 逆向工具, 预测性维护, 飞行遥测, 高度异常