This project trains a 1D CNN on three-phase currents to classify motor condition and optionally predict fault severity.
-
Clone the repository:
git clone <repository-url> cd csa-induction-motor-pytorch
-
Create a Python virtual environment:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies:
pip install --upgrade pip pip install -r requirements.txt
-
Verify PyTorch installation:
python -c "import torch; print(torch.__version__)" -
Prepare data directory:
mkdir -p data/simulink
-
Place your Simulink CSV files in
data/simulink/following the naming conventions above.
- Place your CSVs under
data/simulink. - Each CSV contains columns:
Time,Torque,RPM,Ia,Ib,Ic(order flexible; headers used). - Filename conventions (case-insensitive):
healthy_1..6.csv→ classHealthy, load1..6BearingFault_1..6.csv→ classBearing, severity1..6PhaseImbalance_1..6.csvorStatorShort_1..6.csv→ classStatorShort, severity1..6RotorFault_1..6.csvorBrokenRotorBar_1..6.csv→ classBrokenRotorBar, severity1..6
- The dataset infers labels and severity from filenames. If no number is present, severity defaults to 0 (ignored in training).
python train.py --config config.yamlOR if you want customized training:
python "path/to/PyTorch 1DCNN MCSA/train.py" --data-csv "path/to/PyTorch 1DCNN MCSA/data/simulink" --save-dir "path/to/PyTorch 1DCNN MCSA/runs/exp" --epochs 80 --batch-size 32 --severity-head --severity-loss-weight 0.3 --include-aux--severity-head: enables multi-task prediction with a 6-class severity head.--severity-loss-weight: scales the severity loss term (default0.3).--include-aux: includesRPMandTorque(andvibration/rpmwhen available) as auxiliary channels.- Defaults like
window_length,hop_length,scheduler, etc., are inconfig.yaml.
python "path/to/PyTorch 1DCNN MCSA/evaluate.py" --checkpoint "path/to/PyTorch 1DCNN MCSA/runs/exp/best.pth" --data-csv "path/to/PyTorch 1DCNN MCSA/data/simulink" --save-dir "path/to/PyTorch 1DCNN MCSA/runs/sim_eval"- Saves
confusion_matrix.png. If severity head is enabled, also savesseverity_hist.png.
python "path/to/PyTorch 1DCNN MCSA/predict.py" --checkpoint "path/to/PyTorch 1DCNN MCSA/runs/exp/best.pth" --data-csv "path/to/PyTorch 1DCNN MCSA/data/simulink" --topk 3- Prints top-k class labels and confidences per window.
- Prints
severity_predonly when the top predicted class is notHealthy.
- Classes:
[Healthy, Bearing, BrokenRotorBar, StatorShort]. - Severity head: 6 classes representing severity
1..6. Healthy windows are ignored in severity loss.
- Windows are created by sliding over time series (
window_length,hop_lengthfromconfig.yaml). - Normalization uses z-score by default; scaler computed from training split.
- For Windows,
num_workersdefaults to 0 in notebooks to avoid pickling issues.