A Lightweight Smoke Detector Network Based on Time Series Analysis | 一种基于时间序列的轻量级烟感用神经网络
SmokeNet is a research-oriented PyTorch pipeline for detecting smoke events from multi-channel sensor sequences. It couples a compact 1D CNN with an LSTM backbone to capture local morphology and longer-term temporal dynamics, enabling deployment on resource-constrained platforms.
- 🪶 Lightweight temporal modeling:A 1D CNN + LSTM architecture that captures both local patterns and long-term dependencies.
- 📊 Dual-task learning:Supports fire event binary classification and optional fuel-type multi-class classification (
enable_fuel_classification). - 🧪 Reproducible training:Centralized configuration (
config/default.yaml), fixed random seeds, and visualized metric outputs. - 🧱 Modular data loader:A window-based
WindowDatasetfor handling raw CSV time series and corresponding labels. - 📈 Evaluation utilities:Built-in accuracy metrics, Top-K visualizations, and automatic saving of the best-performing model.
- 🔌 Extensible backbone choices: Drop new architectures into
smokenet/models/and register them inMODEL_REGISTRYto experiment with alternative CNN/RNN/Transformer-style hybrids without changing the training loop.
main.py: CLI entry point, responsible for configuration loading, data preparation, and switching between training and evaluation modes.config/: YAML configuration files (data, model, and training hyperparameters).smokenet/data/: Windowed dataset implementation and CSV loading logic.models/: Optional model builders and backbone implementations.utils/: Utilities for logging, random seed control, plotting, and evaluation metrics.train.py: Training loop, checkpoint saving, and history tracking.
dataset/: Placeholder directory for default data and label files (CSV).
- Ensure Python 3.10+ is available.
- Create environment (conda or venv). Example:
or use
conda env create -f environment.yml conda activate smokenet
pip install -r requirements.txtto install dependencies.
- Place sensor sequences under
dataset/data/*.csvand corresponding labels underdataset/label/*.csv. - Each pair must share the same stem name (e.g.,
sample001.csv). - Labels support per-timestep fire annotations (binary) and an optional fuel-class column that is constant across the sequence.
- Dataset splitting is controlled by
data.split_ratioin the config.
# Train
python main.py --mode train --config config/default.yaml
# Override key hyperparameters
python main.py --mode train --batch-size 16 --learning-rate 5e-4 --device cuda- Training artifacts (weights, figures) are stored under
outputs/. - Fuel classification is enabled when both the dataset provides fuel labels and
model.enable_fuel_classificationistrue.
Key fields in config/default.yaml:
data.window_size: Sliding window length for sequences.data.channels: Expected sensor channels per timestep.model.cnn_hidden,model.lstm_hidden,model.dropout: Model capacity and regularization.training.batch_size,training.learning_rate,training.num_epochs: Optimization settings.
- Metrics: fire accuracy (masked), optional fuel accuracy, loss curves.
- Checkpoints: best/last weights auto-saved to
outputs/weights/. - Visualizations: accuracy plots under
outputs/figures/.
- Plug-and-play models: Add a new
BaseTemporalModelsubclass undersmokenet/models/(e.g.,transformer.py) and register it insideMODEL_REGISTRYinsmokenet/models/__init__.py. Once registered, select it viamodel.namein the config without touching the rest of the pipeline. - Configuration-first: Hyperparameters, feature flags (e.g.,
enable_fuel_classification), and data settings live in YAML so new experiments can be driven by config overrides instead of code edits.
SmokeNet is released under the MIT License. You are free to use, modify, and distribute the code (including in commercial products) provided you retain the copyright and license notice in derivative works. Contributions are welcome under the same terms.
If you build upon SmokeNet, please cite the repository and your configuration to ensure reproducibility.
This project benefited from the code implementation ideas and documentation writing suggestions provided by OpenAI Codex. We would like to express our sincere thanks.
Built with ❤️ by the SmokeNet contributors.