Skip to content

Commit faf9987

Browse files
Squashed 'tinyml-modelzoo/' changes from ab301c33..fd0815a1
fd0815a1 TINYML_ALGO-705 442deb8d Pull request #33: Updated dataset names and removed redundant lines from config 9de8a1f0 Updated dataset names and removed redundant lines from config 61be623e Pull request #32: Feature/SL EDGEAI-45 enable cc2755xxx device support cls 4k npu model and documentation in ccstudio 93057540 SL_EDGEAI-52 - Enable CC13xx devices for Fan Blade 33043973 SL_EDGEAI-45, SL_EDGEAI-59: Add CC2755 and CC35X1 configs for fan blade fault classification b5c6ac42 Pull request #31: Added 9 classification models and 1 new application (gearbox fault) 6d9594f4 Added error handling and fixed linting issue 7ee77925 Added 9 classification models and 1 new application (gearbox fault) git-subtree-dir: tinyml-modelzoo git-subtree-split: fd0815a1bba5a990b619a80afb24dc5960d4185a
1 parent 350251f commit faf9987

22 files changed

Lines changed: 1593 additions & 21 deletions

README.md

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ tinyml-modelzoo/
109109
|--------|-----|-------------|-------|
110110
| CC2755 | CDE | 96 MHz Arm Cortex-M33 wireless MCU | Optimized for PIR/wireless apps |
111111
| CC1312 | No | Arm Cortex-M4F wireless MCU | Sub-1GHz |
112+
| CC1314 | No | Arm Cortex-M33 wireless MCU | Sub-1GHz |
112113
| CC1352 | No | Arm Cortex-M4F wireless MCU | Sub-1GHz |
113114
| CC1354 | No | Arm Cortex-M33 wireless MCU | Sub-1GHz |
114115
| CC35X1 | CDE | Arm Cortex-M33 wireless MCU | Wi-Fi + BLE combo |
@@ -259,6 +260,7 @@ These applications are designed for specific use cases with optimized models and
259260
| **ac_arc_fault** | arc_fault | F280013, F280015, F28003, F28004, F2837, F28P55, F28P65, MSPM0G3507, MSPM0G3519, MSPM0G5187, MSPM33C32, F29H85, AM13E2, AM263 | Detect AC arc faults in electrical systems |
260261
| **dc_arc_fault** | arc_fault | F280013, F280015, F28003, F28004, F2837, F28P55, F28P65, MSPM0G3507, MSPM0G3519, MSPM0G5187, MSPM33C32, F29H85, AM13E2, AM263 | Detect DC arc faults from current waveforms for electrical safety |
261262
| **ecg_classification** | ecg_classification | MSPM0G3507, MSPM0G5187, MSPM0G3519 | Classify normal vs anomalous heartbeats from ECG signals |
263+
| **gearbox_fault_detection** | gearbox_fault | MSPM0G3507, MSPM0G3519, MSPM0G5187 | Classify gearbox operating conditions (healthy vs broken tooth) from vibration data |
262264
| **blower_imbalance** | motor_fault | F280013, F280015, F28003, F28004, F2837, F28P55, F28P65, MSPM0G3507, MSPM0G3519, MSPM0G5187, MSPM33C32, F29H85, AM13E2, AM263 | Detect blade imbalance in HVAC blowers using 3-phase motor currents |
263265
| **fan_blade_fault_classification** | motor_fault | F280013, F280015, F28003, F28004, F2837, F28P55, F28P65, MSPM0G3507, MSPM0G3519, MSPM0G5187, MSPM33C32, F29H85, AM13E2, AM263 | Detect faults in BLDC fans from accelerometer data |
264266
| **motor_bearing_fault** | motor_fault | F280013, F280015, F28003, F28004, F2837, F28P55, F28P65, MSPM0G3507, MSPM0G3519, MSPM0G5187, MSPM33C32, F29H85, AM13E2, AM263 | Classify 5 bearing fault types + normal operation from vibration data |
@@ -268,12 +270,12 @@ These applications are designed for specific use cases with optimized models and
268270
| **MNIST_image_classification** | image_classification | MSPM0G3507, MSPM0G3519, MSPM0G5187, MSPM33C32 | Handwritten digit recognition (MNIST dataset) |
269271

270272
### Summary by Task Type:
271-
- **Generic Timeseries Tasks** (22 examples): Support all target devices and can be adapted to your custom datasets
272-
- Classification: 8 examples (1 base + 7 real-world applications)
273+
- **Generic Timeseries Tasks** (23 examples): Support all target devices and can be adapted to your custom datasets
274+
- Classification: 9 examples (1 base + 8 real-world applications)
273275
- Regression: 5 examples (1 base + 4 real-world applications)
274276
- Forecasting: 3 examples (1 base + 2 real-world applications)
275277
- Anomaly Detection: 6 examples (1 base + 5 application variants)
276-
- **Application-Specific Tasks** (10 examples): arc_fault (2), motor_fault (3), grid_fault_detection (1), mosfet_temp_prediction (1), pir_detection (1), ecg_classification (1), image_classification (1)
278+
- **Application-Specific Tasks** (11 examples): arc_fault (2), motor_fault (3), grid_fault_detection (1), gearbox_fault_detection (1), mosfet_temp_prediction (1), pir_detection (1), ecg_classification (1), image_classification (1)
277279

278280
---
279281

@@ -288,14 +290,15 @@ These applications are designed for specific use cases with optimized models and
288290
| 3 | [motor_bearing_fault](examples/motor_bearing_fault/) | Multivariate | Classify 5 bearing fault types + normal operation from vibration data. |
289291
| 4 | [blower_imbalance](examples/blower_imbalance/) | Multivariate | Detect blade imbalance in HVAC blowers using 3-phase motor currents. |
290292
| 5 | [fan_blade_fault_classification](examples/fan_blade_fault_classification/) | Multivariate | Detect faults in BLDC fans from accelerometer data. |
291-
| 6 | [electrical_fault](examples/electrical_fault/) | Multivariate | Classify transmission line faults using voltage and current. |
292-
| 7 | [grid_stability](examples/grid_stability/) | Multivariate | Predict power grid stability from node parameters. |
293-
| 8 | [gas_sensor](examples/gas_sensor/) | Multivariate | Identify gas type and concentration from sensor array data. |
294-
| 9 | [branched_model_parameters](examples/branched_model_parameters/) | Multivariate | Human Activity Recognition from accelerometer/gyroscope data. |
295-
| 10 | [ecg_classification](examples/ecg_classification/) | Multivariate | Classify normal vs anomalous heartbeats from ECG signals. |
296-
| 11 | [nilm_appliance_usage_classification](examples/nilm_appliance_usage_classification/) | Multivariate | Non-Intrusive Load Monitoring - identify active appliances. |
297-
| 12 | [PLAID_nilm_classification](examples/PLAID_nilm_classification/) | Multivariate | Appliance identification using the PLAID dataset. |
298-
| 13 | [pir_detection](examples/pir_detection/) | Multivariate | Detect presence/motion using PIR sensor data. |
293+
| 6 | [gearbox_fault_detection](examples/gearbox_fault_detection/) | Multivariate | Classify gearbox operating conditions (healthy vs broken tooth) from vibration. |
294+
| 7 | [electrical_fault](examples/electrical_fault/) | Multivariate | Classify transmission line faults using voltage and current. |
295+
| 8 | [grid_stability](examples/grid_stability/) | Multivariate | Predict power grid stability from node parameters. |
296+
| 9 | [gas_sensor](examples/gas_sensor/) | Multivariate | Identify gas type and concentration from sensor array data. |
297+
| 10 | [branched_model_parameters](examples/branched_model_parameters/) | Multivariate | Human Activity Recognition from accelerometer/gyroscope data. |
298+
| 11 | [ecg_classification](examples/ecg_classification/) | Multivariate | Classify normal vs anomalous heartbeats from ECG signals. |
299+
| 12 | [nilm_appliance_usage_classification](examples/nilm_appliance_usage_classification/) | Multivariate | Non-Intrusive Load Monitoring - identify active appliances. |
300+
| 13 | [PLAID_nilm_classification](examples/PLAID_nilm_classification/) | Multivariate | Appliance identification using the PLAID dataset. |
301+
| 14 | [pir_detection](examples/pir_detection/) | Multivariate | Detect presence/motion using PIR sensor data. |
299302

300303
### Regression Examples
301304

@@ -355,19 +358,30 @@ For detailed guidelines, see [NPU Configuration Guidelines](docs/NPU_CONFIGURATI
355358
| `CLS_100_NPU` | ~100 | CNN | Yes | Ultra-compact model |
356359
| `CLS_500_NPU` | ~500 | CNN | Yes | Compact model |
357360
| `CLS_1k_NPU` | ~1K | CNN | Yes | Lightweight 2-layer CNN |
361+
| `CLS_1.2k_NPU` | ~1.2K | CNN | Yes | Compact model for ultra-low power devices |
362+
| `CLS_1.5k_NPU` | ~1.5K | CNN | Yes | 3-layer model with balanced performance |
363+
| `CLS_1.9k_NPU` | ~1.9K | CNN | Yes | Efficient 3-layer model |
358364
| `CLS_2k_NPU` | ~2K | CNN | Yes | 2-layer model |
365+
| `CLS_2.8k_NPU` | ~2.8K | CNN | Yes | Improved accuracy with compact footprint |
366+
| `CLS_3.1k_NPU` | ~3.1K | CNN | Yes | Higher accuracy model |
359367
| `CLS_ResAdd_3k` | ~3K | ResNet (Add) | No | Residual connections with addition |
360368
| `CLS_ResCat_3k` | ~3K | ResNet (Cat) | No | Residual connections with concatenation |
369+
| `CLS_3.9k_NPU` | ~3.9K | CNN | Yes | Advanced 3-layer model |
361370
| `CLS_4k_NPU` | ~4K | CNN | Yes | Balanced model |
371+
| `CLS_4.2k_NPU` | ~4.2K | CNN | Yes | Optimized 4-layer model |
372+
| `CLS_5k_NPU` | ~5K | CNN | Yes | Mid-range model |
362373
| `CLS_6k_NPU` | ~6K | CNN (DW-Sep) | Yes | Depthwise separable |
363374
| `CLS_8k_NPU` | ~8K | CNN (DW-Sep) | Yes | Depthwise separable |
364375
| `CLS_13k_NPU` | ~13K | CNN | Yes | Higher capacity |
365376
| `CLS_20k_NPU` | ~20K | CNN | Yes | High capacity |
377+
| `CLS_40k_NPU` | ~40K | CNN | Yes | Advanced model for complex tasks |
366378
| `CLS_55k_NPU` | ~55K | CNN | Yes | Maximum accuracy |
367379
| `ArcFault_model_200_t` | ~200 | Specialized | No | Arc fault detection |
368380
| `ArcFault_model_300_t` | ~300 | Specialized | No | Arc fault with more capacity |
369381
| `ArcFault_model_700_t` | ~700 | Specialized | No | Arc fault medium model |
370382
| `ArcFault_model_1400_t` | ~1.4K | Specialized | No | Arc fault high accuracy |
383+
| `GearboxFault_model_1.2k_t` | ~1.2K | CNN | Yes | Gearbox fault detection |
384+
| `GearboxFault_model_1.5k_t` | ~1.5K | CNN | Yes | Gearbox fault with more capacity |
371385
| `MotorFault_model_1_t` | Varies | Specialized | No | Motor bearing fault detection |
372386
| `MotorFault_model_2_t` | Varies | Specialized | No | Motor fault variant 2 |
373387
| `MotorFault_model_3_t` | Varies | Specialized | No | Motor fault variant 3 |
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
common:
2+
task_type: generic_timeseries_classification
3+
target_device: MSPM0G5187
4+
5+
dataset:
6+
dataset_name: electrical_fault
7+
input_data_path: https://software-dl.ti.com/C2000/esd/mcu_ai/01_04_00/datasets/electrical_fault_6class_dataset.zip
8+
9+
data_processing_feature_extraction:
10+
data_proc_transforms: ['SimpleWindow']
11+
frame_size: 128
12+
stride_size: 0.01
13+
variables: 3
14+
feature_extraction_name: Custom_Default
15+
feat_ext_transform: ['FFT_Q15', 'DC_REMOVE', 'Q15_MAG', 'BIN_Q15', 'LOG_DB', 'CONCAT']
16+
feature_size_per_frame: 32
17+
num_frame_concat: 8
18+
19+
training:
20+
model_name: ElectricalFault_model_40k_t
21+
training_epochs: 25
22+
num_gpus: 0
23+
24+
testing: {}
25+
26+
compilation: {}
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
import os
2+
import requests as re
3+
import zipfile
4+
import pandas as pd
5+
import shutil
6+
7+
# Project Definition
8+
DATASET_NAME = "electrical_fault_6class"
9+
10+
# Dataset definition
11+
DATASET_URL = "https://software-dl.ti.com/C2000/esd/mcu_ai/01_04_00/datasets/electrical_fault_raw.zip"
12+
DATASET_FILE_NAME = "classData.csv"
13+
independent_variables = ["Ia", "Ib", "Ic", "Va", "Vb", "Vc"]
14+
dependent_variables = ["G", "C", "B", "A"] # Ground, Node C, Node B, Node A
15+
16+
# Dataset Processing
17+
NUM_SPLITS = 5
18+
class_names = [
19+
"no_fault",
20+
"bc_fault",
21+
"abc_fault",
22+
"ag_fault",
23+
"abg_fault",
24+
"abcg_fault",
25+
]
26+
27+
def download_data():
28+
print("Downloading dataset")
29+
data = re.get(DATASET_URL)
30+
if data.status_code != 200:
31+
raise Exception(f"Failed to download dataset. HTTP status code: {data.status_code}")
32+
with open(f"{DATASET_NAME}.zip", "wb") as f:
33+
f.write(data.content)
34+
return None
35+
36+
def extract_data():
37+
print("Extracting dataset")
38+
with zipfile.ZipFile(f"{DATASET_NAME}.zip", 'r') as zip_ref:
39+
zip_ref.extractall(DATASET_NAME)
40+
return None
41+
42+
def load_data():
43+
data = pd.read_csv(f"{DATASET_NAME}/{DATASET_FILE_NAME}", index_col=False)
44+
columns = independent_variables + dependent_variables
45+
data = data[columns]
46+
# Map the four binary columns to a single target class
47+
def map_to_class(row):
48+
bits = (row['G'], row['C'], row['B'], row['A'])
49+
# Mapping: (G,C,B,A) -> class index
50+
if bits == (0,0,0,0):
51+
return 0 # NO_FAULT
52+
elif bits == (0,1,1,0):
53+
return 1 # BC_FAULT
54+
elif bits == (0,1,1,1):
55+
return 2 # ABC_FAULT
56+
elif bits == (1,0,0,1):
57+
return 3 # AG_FAULT
58+
elif bits == (1,0,1,1):
59+
return 4 # ABG_FAULT
60+
elif bits == (1,1,1,1):
61+
return 5 # ABCG_FAULT
62+
else:
63+
# Unexpected combination, assign -1 (will become "unknown")
64+
return -1
65+
data['Target'] = data.apply(map_to_class, axis=1)
66+
# Convert to string labels for folder naming
67+
data['Target'] = data['Target'].apply(lambda x: class_names[x] if 0 <= x < len(class_names) else "unknown")
68+
return data
69+
70+
def store_datafiles(df):
71+
if not os.path.exists("classes"):
72+
os.mkdir("classes")
73+
74+
for idx, target in enumerate(class_names):
75+
if not os.path.exists(f"classes/class_{idx}_{target}"):
76+
os.mkdir(f"classes/class_{idx}_{target}")
77+
current_target_df = df[df['Target'] == target]
78+
num_splits = NUM_SPLITS
79+
chunk_size = len(current_target_df) // num_splits
80+
current_target_dfs = [current_target_df[i*chunk_size:(i+1)*chunk_size] for i in range(num_splits)]
81+
for df_idx, current_target_df in enumerate(current_target_dfs):
82+
current_target_df = current_target_df.drop(['Target'], axis=1)
83+
current_target_df.to_csv(f"classes/class_{idx}_{target}/{target}_{df_idx}.csv", index=False)
84+
print(f"Created classes/class_{idx}_{target}")
85+
86+
def cleanup():
87+
if os.path.exists(DATASET_NAME):
88+
shutil.rmtree(DATASET_NAME)
89+
zip_path = f"{DATASET_NAME}.zip"
90+
if os.path.exists(zip_path):
91+
os.remove(zip_path)
92+
93+
def zip_files():
94+
print(f"Zipping the classes into {DATASET_NAME}_dataset.zip")
95+
shutil.make_archive(f"{DATASET_NAME}_dataset", 'zip', root_dir='.', base_dir='classes')
96+
shutil.rmtree('classes', ignore_errors=True)
97+
98+
if __name__ == '__main__':
99+
download_data()
100+
extract_data()
101+
df = load_data()
102+
store_datafiles(df)
103+
zip_files()
104+
cleanup()

examples/electrical_fault/readme.md

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ The Electrical Fault Dataset is a multivariate time series dataset. It is obtain
88

99
The fault can be Line-to-line, Line-to-ground, Line-to-line-to-ground and more. Line-to-line (LL) fault is a fault between two phase conductors (e.g., A-B). This typically appears as a short-duration high-energy event affecting particular frequency bins. Line-to-ground (LG) fault: a fault between a phase conductor and ground. Pattern differs from LL faults and can be identified using combinations of voltage and current measurements. LLG / LLLG: multi-conductor faults involving two or three lines and possibly ground. These create distinct signatures across voltage and current channels.
1010

11+
Users can choose between two dataset options, each processed by a different script to produce a distinct output file:
12+
- **2-class dataset** (`detect_dataset.xlsx`): Processed by `electrical_fault.py` to create `electrical_fault_dataset.zip` for fault detection (binary classification - fault vs no fault)
13+
- **6-class dataset** (`classData.csv`): Processed by `electrical_fault_6class.py` to create `electrical_fault_6class_dataset.zip` for fault type classification (6 fault types based on G,C,B,A combinations)
14+
1115
<p align="center">
1216
<img src="assets/simulink.png" width="280" alt="Simulink Model">
1317
</p>
@@ -21,26 +25,37 @@ There are two dataset files present in the compressed zip: [electrical_fault_raw
2125
- There are 4 target variables i.e G (Ground), C (Node C), B (Node B), A (NodeA). The value of each target is either 0 or 1.
2226
- Examples [G, C, B, A]:
2327
- [0, 0, 0, 0] means No Fault
28+
- [0, 1, 1, 0] means LL Fault btw Node B and Node C
29+
- [0, 1, 1, 1] means LLL Fault btw all Nodes
2430
- [1, 0, 0, 1] means LG Fault btw Ground and Node A
25-
- [0, 0, 1, 1] means LL Fault btw Node A and Node B
2631
- [1, 0, 1, 1] means LLG Fault btw Node A, Node B and Ground
27-
- [0, 1, 1, 1] means LLL Fault btw all Nodes
2832
- [1, 1, 1, 1] means LLLG Fault btw all Nodes and Ground
2933

30-
For this example we will be using `detect_dataset.xlsx` to detect whether there is electrical fault or not.
34+
Depending on the dataset chosen, users can either detect whether there is an electrical fault (binary classification) or classify the type of fault (6-class classification).
3135

3236
## Downloading dataset
3337

34-
Prepare the zipped dataset by running the electrical_fault python file. The script will create zipped dataset as `electrical_fault_dataset.zip`.
38+
Users can prepare the zipped dataset using either of two python scripts, depending on which dataset they want to use:
39+
40+
**For 2-class dataset (fault detection):**
3541
```bash
3642
cd examples/electrical_fault
3743
python electrical_fault.py
3844
```
39-
The path of this zipped dataset file is already mentioned in [configuration](config.yaml) yaml, make sure it is same.
45+
This creates `electrical_fault_dataset.zip`
46+
47+
**For 6-class dataset (fault type classification):**
48+
```bash
49+
cd examples/electrical_fault
50+
python electrical_fault_6class.py
51+
```
52+
This creates `electrical_fault_6class_dataset.zip`
53+
54+
The path to the appropriate zipped dataset file should be mentioned in [configuration](config.yaml) yaml under `dataset.input_data_path`, make sure it matches the script you ran.
4055

4156
```yaml
4257
dataset:
43-
input_data_path: 'examples/electrical_fault/electrical_fault_dataset.zip'
58+
input_data_path: 'examples/electrical_fault/electrical_fault_dataset.zip' # OR 'examples/electrical_fault/electrical_fault_6class_dataset.zip'
4459
```
4560
4661
## Usage in Tiny ML ModelZoo
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
common:
2+
task_type: motor_fault
3+
target_device: CC1312
4+
dataset:
5+
dataset_name: fan_blade_fault
6+
input_data_path: https://software-dl.ti.com/C2000/esd/mcu_ai/01_04_00/datasets/fan_blade_fault_dsi.zip
7+
data_processing_feature_extraction:
8+
data_proc_transforms: []
9+
feature_extraction_name: Input256_FFTBIN_16Feature_8Frame_3InputChannel_removeDC_2D1
10+
# feature_extraction_name: Input256_FFTBIN_16Feature_8Frame_3InputChannel_removeDC_1D
11+
# feature_extraction_name: Input256_FFT_128Feature_1Frame_3InputChannel_removeDC_2D1
12+
# feature_extraction_name: Input128_RAW_128Feature_1Frame_3InputChannel_removeDC_2D1
13+
# feature_extraction_name: Custom_MotorFault
14+
# frame_size: 256
15+
# feature_size_per_frame: 128
16+
# num_frame_concat: 8
17+
# normalize_bin: 1
18+
# stacking: 2D1
19+
# feat_ext_transform: [ 'FFT_FE', 'FFT_POS_HALF', 'DC_REMOVE', 'ABS', 'LOG_DB', 'CONCAT' ]
20+
# offset: 0
21+
# scale: 1
22+
# frame_skip: 1
23+
# log_mul: 20
24+
# log_base: 10
25+
# log_threshold: 1e-100
26+
variables: 3
27+
training:
28+
model_name: CLS_4k_NPU
29+
model_config: ''
30+
batch_size: 256
31+
training_epochs: 20
32+
num_gpus: 0
33+
testing: {}
34+
compilation: {}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
common:
2+
task_type: motor_fault
3+
target_device: CC1314
4+
dataset:
5+
dataset_name: fan_blade_fault
6+
input_data_path: https://software-dl.ti.com/C2000/esd/mcu_ai/01_04_00/datasets/fan_blade_fault_dsi.zip
7+
data_processing_feature_extraction:
8+
data_proc_transforms: []
9+
feature_extraction_name: Input256_FFTBIN_16Feature_8Frame_3InputChannel_removeDC_2D1
10+
# feature_extraction_name: Input256_FFTBIN_16Feature_8Frame_3InputChannel_removeDC_1D
11+
# feature_extraction_name: Input256_FFT_128Feature_1Frame_3InputChannel_removeDC_2D1
12+
# feature_extraction_name: Input128_RAW_128Feature_1Frame_3InputChannel_removeDC_2D1
13+
# feature_extraction_name: Custom_MotorFault
14+
# frame_size: 256
15+
# feature_size_per_frame: 128
16+
# num_frame_concat: 8
17+
# normalize_bin: 1
18+
# stacking: 2D1
19+
# feat_ext_transform: [ 'FFT_FE', 'FFT_POS_HALF', 'DC_REMOVE', 'ABS', 'LOG_DB', 'CONCAT' ]
20+
# offset: 0
21+
# scale: 1
22+
# frame_skip: 1
23+
# log_mul: 20
24+
# log_base: 10
25+
# log_threshold: 1e-100
26+
variables: 3
27+
training:
28+
model_name: CLS_4k_NPU
29+
model_config: ''
30+
batch_size: 256
31+
training_epochs: 20
32+
num_gpus: 0
33+
testing: {}
34+
compilation: {}

0 commit comments

Comments
 (0)