├── .gitmodules ├── LICENSE ├── README.md ├── assets └── mcu_ai_repo_connection.png ├── git_pull_all.sh ├── scripts └── git_update_all.sh ├── tinyml-docs └── README.md ├── tinyml-modelmaker ├── .gitignore ├── LICENSE ├── README.md ├── config_byom_for_compilation.yaml ├── config_timeseries_anomalydetection_ecg.yaml ├── config_timeseries_classification_dsi.yaml ├── config_timeseries_classification_dsk.yaml ├── config_timeseries_classification_ecg.yaml ├── config_timeseries_classification_fan_blade_dsi.yaml ├── config_timeseries_classification_fan_blower_imbalance_dsh.yaml ├── config_timeseries_classification_helloworld_dsg.yaml ├── config_timeseries_classification_motor_bearing_dsk.yaml ├── config_timeseries_regression_dsi.yaml ├── data │ └── descriptions │ │ ├── description_timeseries.json │ │ ├── description_timeseries.yaml │ │ ├── help_timeseries.md │ │ └── readme.txt ├── docker │ ├── Dockerfile │ ├── docker_build.sh │ ├── docker_run.sh │ ├── docker_setup.sh │ ├── proxy_setup.sh │ └── readme.txt ├── docs │ ├── AddingFeatureExtractors.md │ ├── AddingModalities.md │ ├── AddingModels.md │ ├── BYOM_for_Compilation.md │ ├── Configuring_Model_layer_params.md │ ├── LabelStudioJSONFormat.png │ ├── UnderstandingConfigFile.md │ ├── Windows_Subsytem_for_Linux.md │ └── older_readme.md ├── examples │ ├── branched_model_parameters │ │ ├── config_timeseries_classification_wisdm.yaml │ │ ├── readme.md │ │ ├── readme │ │ │ └── model.onnx.png │ │ ├── residual_network_config.yaml │ │ └── wisdm.py │ ├── data_processing_and_feature_extraction │ │ ├── config_timeseries_classification_motor_fault_dsk.yaml │ │ └── readme.md │ ├── electrical_fault │ │ ├── assets │ │ │ └── simulink.png │ │ ├── config_classification_electrical_fault.yaml │ │ ├── electrical_fault.py │ │ └── readme.md │ ├── fan_blade_fault_classification │ │ ├── assets │ │ │ ├── Blade Damage.jpg │ │ │ ├── Blade Imbalance.jpg │ │ │ ├── Blade Obstruction.jpg │ │ │ ├── Demo Setup.jpg │ │ │ ├── Histogram_Class_Score_differences_test.png │ │ │ ├── Normal.jpg │ │ │ ├── One_vs_Rest_MultiClass_ROC_test.png │ │ │ ├── adxl355_pmdz_pinout.png │ │ │ ├── eAI_data_acq_dap_f28p55x.zip │ │ │ ├── eAI_mfd_eval_f28p55x.zip │ │ │ ├── f28p55_launchpad_pinout.jpg │ │ │ ├── fan_blade_demo_model_composer.png │ │ │ ├── fpr_tpr_thresholds.csv │ │ │ ├── live_capture.png │ │ │ ├── pca_on_feature_extracted_train_data.png │ │ │ └── pca_on_feature_extracted_validation_data.png │ │ ├── config_timeseries_classification_fan_blade_dsi.yaml │ │ └── readme.md │ ├── goodness_of_fit_test │ │ ├── GoF_plots │ │ │ ├── arc_fault_dsi_GoF_frame_size_1024.png │ │ │ ├── arc_fault_dsi_GoF_frame_size_2048.png │ │ │ ├── arc_fault_dsi_GoF_frame_size_256.png │ │ │ ├── arc_fault_dsi_GoF_frame_size_4096.png │ │ │ ├── arc_fault_dsi_GoF_frame_size_512.png │ │ │ ├── motor_dsk3inp_GoF_frame_size_256.png │ │ │ ├── motor_dsk3inp_GoF_frame_size_256_40Hz.png │ │ │ ├── motor_dsk_GoF_frame_size_256.png │ │ │ ├── motor_dsk_GoF_frame_size_256_40Hz.png │ │ │ └── motor_dsk_GoF_frame_size_256_40Hz_m1.png │ │ ├── config_timeseries_classification_motor_fault_dsk3.yaml │ │ └── readme.md │ ├── grid_stability │ │ ├── assets │ │ │ └── four_node_start.svg │ │ ├── config_classification_grid_stability.yaml │ │ ├── grid_stability.py │ │ └── readme.md │ ├── how_good_is_your_feature_extraction │ │ ├── arc_fault_dsi │ │ │ ├── pca_on_feature_extracted_train_data.png │ │ │ └── pca_on_feature_extracted_validation_data.png │ │ ├── arc_fault_dsk │ │ │ ├── pca_on_feature_extracted_train_data.png │ │ │ └── pca_on_feature_extracted_validation_data.png │ │ ├── motor_bearing_fault_dsk │ │ │ ├── pca_on_feature_extracted_train_data_MotorFault_128Input_RAW_128Feature_1Frame_3InputChannel_removeDC_2D1.png │ │ │ ├── pca_on_feature_extracted_train_data_MotorFault_256Input_FFTBIN_16Feature_8Frame_3InputChannel_removeDC_1D.png │ │ │ ├── pca_on_feature_extracted_train_data_MotorFault_256Input_FFTBIN_16Feature_8Frame_3InputChannel_removeDC_2D1.png │ │ │ ├── pca_on_feature_extracted_train_data_MotorFault_256Input_FFT_128Feature_1Frame_3InputChannel_removeDC_2D1.png │ │ │ ├── pca_on_feature_extracted_validation_data_MotorFault_128Input_RAW_128Feature_1Frame_3InputChannel_removeDC_2D1.png │ │ │ ├── pca_on_feature_extracted_validation_data_MotorFault_256Input_FFTBIN_16Feature_8Frame_3InputChannel_removeDC_1D.png │ │ │ ├── pca_on_feature_extracted_validation_data_MotorFault_256Input_FFTBIN_16Feature_8Frame_3InputChannel_removeDC_2D1.png │ │ │ └── pca_on_feature_extracted_validation_data_MotorFault_256Input_FFT_128Feature_1Frame_3InputChannel_removeDC_2D1.png │ │ └── readme.md │ ├── nilm_appliance_usage_classification │ │ ├── config_timeseries_classification_nilm.yaml │ │ └── readme.md │ └── post_training_analysis │ │ ├── arc_fault_dsi │ │ ├── Histogram_Class_Score_differences_test.png │ │ ├── One_vs_Rest_MultiClass_ROC_test.png │ │ └── fpr_tpr_thresholds.csv │ │ ├── arc_fault_dsk │ │ ├── Histogram_Class_Score_differences_test.png │ │ ├── One_vs_Rest_MultiClass_ROC_test.png │ │ └── fpr_tpr_thresholds.csv │ │ ├── motor_bearing_fault_dsk │ │ ├── Histogram_Class_Score_differences_test.png │ │ ├── One_vs_Rest_MultiClass_ROC_test.png │ │ └── fpr_tpr_thresholds.csv │ │ └── readme.md ├── misc │ ├── ArcFault_model_x_t.yaml │ ├── MotorFault_model_x_t.yaml │ ├── TimeSeries_Generic_x_t.yaml │ ├── augmenter_config.yaml │ └── tcresnet.yaml ├── pyproject.toml ├── requirements.txt ├── run_tinyml_modelmaker.sh ├── scripts │ ├── get_model_performance_data.py │ ├── labelstudio2tinyverse_univariate.py │ └── run_generate_description.py ├── setup.py ├── setup.sh ├── setup_all.sh ├── setup_armclang_tools.sh ├── setup_c2000ware.sh ├── setup_cg_tools.sh └── tinyml_modelmaker │ ├── __init__.py │ ├── ai_modules │ ├── __init__.py │ ├── common │ │ ├── __init__.py │ │ ├── compilation │ │ │ ├── LICENSE.txt │ │ │ ├── __init__.py │ │ │ └── tinyml_benchmark.py │ │ └── datasets │ │ │ ├── __init__.py │ │ │ └── dataset_utils.py │ └── timeseries │ │ ├── __init__.py │ │ ├── compilation │ │ └── __init__.py │ │ ├── constants.py │ │ ├── datasets │ │ └── __init__.py │ │ ├── descriptions.py │ │ ├── params.py │ │ ├── runner.py │ │ └── training │ │ ├── __init__.py │ │ └── tinyml_tinyverse │ │ ├── LICENSE.txt │ │ ├── __init__.py │ │ ├── device_run_info.py │ │ ├── timeseries_anomalydetection.py │ │ ├── timeseries_classification.py │ │ └── timeseries_regression.py │ ├── run_tinyml_modelmaker.py │ ├── utils │ ├── __init__.py │ ├── config_dict.py │ ├── download_utils.py │ └── misc_utils.py │ └── version.py ├── tinyml-modeloptimization ├── .gitignore ├── LICENSE ├── README.md └── torchmodelopt │ ├── README.md │ ├── examples │ ├── README.md │ ├── audio_keyword_spotting │ │ ├── README.md │ │ ├── main.py │ │ ├── quant_cal_indices_mlperf.txt │ │ ├── requirements.txt │ │ └── trained_models │ │ │ ├── kws_dscnn_pb2pth_checkpoint.pth │ │ │ ├── kws_dscnn_pb2pth_metadata.json │ │ │ └── kws_dscnn_pb2pth_model.pth │ ├── fmnist_image_classification │ │ ├── README.md │ │ ├── fmnist_tinpu_qat.py │ │ └── run_fmnist.py │ └── motor_fault_time_series_classification │ │ ├── README.md │ │ ├── motor_fault_classification_tinpu_quant.py │ │ └── motor_fault_dataset.csv │ ├── pyproject.toml │ ├── requirements │ └── requirements.txt │ ├── setup.py │ ├── setup.sh │ ├── tinyml_torchmodelopt │ ├── __init__.py │ ├── quantization │ │ ├── __init__.py │ │ ├── base │ │ │ └── fx │ │ │ │ ├── __init__.py │ │ │ │ ├── bias_calibration.py │ │ │ │ ├── functional_utils.py │ │ │ │ ├── observer_types.py │ │ │ │ ├── observer_utils.py │ │ │ │ ├── qconfig_types.py │ │ │ │ ├── quant_base.py │ │ │ │ └── quant_utils.py │ │ ├── common.py │ │ ├── generic │ │ │ └── __init__.py │ │ └── tinpu │ │ │ ├── __init__.py │ │ │ ├── quant_fx.py │ │ │ ├── quant_helper_func.py │ │ │ ├── quant_modules.py │ │ │ └── quant_utils.py │ └── surgery │ │ ├── README.md │ │ ├── __init__.py │ │ ├── custom_modules.py │ │ ├── custom_surgery_functions.py │ │ ├── replacer.py │ │ └── surgery.py │ └── version.py ├── tinyml-modelzoo ├── README.md └── graphs │ ├── cycles_vs_memory_usage_plots │ ├── arcFault_c28_total_memory_vs_cycles.png │ ├── generic_c28_total_memory_vs_cycles.png │ └── motorfault_c28_total_memory_vs_cycles.png │ └── model_vs_accuracy_plots │ ├── MotorFault_128Input_RAW_128Feature_1Frame_3InputChannel_removeDC_2D1_accuracy_comparison.png │ ├── MotorFault_256Input_FFTBIN_16Feature_8Frame_3InputChannel_removeDC_1D_accuracy_comparison.png │ ├── MotorFault_256Input_FFTBIN_16Feature_8Frame_3InputChannel_removeDC_2D1_accuracy_comparison.png │ └── MotorFault_256Input_FFT_128Feature_1Frame_3InputChannel_removeDC_2D1_accuracy_comparison.png └── tinyml-tinyverse ├── .gitignore ├── LICENSE ├── README.md ├── pyproject.toml ├── requirements ├── requirements.txt └── requirements_ti_packages.txt ├── setup.py ├── setup.sh ├── setup_cpu.sh └── tinyml_tinyverse ├── __init__.py ├── common ├── __init__.py ├── augmenters │ ├── LICENSE │ ├── __init__.py │ ├── add_noise.py │ ├── base.py │ ├── convolve.py │ ├── crop.py │ ├── drift.py │ ├── dropout.py │ ├── linear_transform.py │ ├── pool.py │ ├── quantize.py │ ├── resize.py │ ├── reverse.py │ └── time_warp.py ├── compilation │ ├── __init__.py │ └── tvm_input_config.py ├── datasets │ ├── __init__.py │ ├── generic_dataloaders.py │ └── timeseries_dataset.py ├── models │ ├── __init__.py │ ├── generic_autoencoder_models.py │ ├── generic_classification_models.py │ ├── generic_feature_extraction_models.py │ ├── generic_model_spec.py │ ├── generic_models.py │ ├── generic_regression_models.py │ └── tinynn.py ├── transforms │ ├── __init__.py │ ├── basic_transforms.py │ ├── haar.py │ └── hadamard.py └── utils │ ├── __init__.py │ ├── data_utils.py │ ├── gof_utils.py │ ├── load_weights.py │ ├── mdcl_utils.py │ ├── misc_utils.py │ ├── print_utils.py │ ├── py_utils.py │ └── utils.py └── references ├── __init__.py ├── common ├── __init__.py └── compilation.py ├── timeseries_anomalydetection ├── __init__.py ├── test_onnx.py ├── test_onnx_cls.py └── train.py ├── timeseries_classification ├── __init__.py ├── test_onnx.py └── train.py ├── timeseries_regression ├── __init__.py ├── test_onnx.py └── train.py └── version.py /.gitmodules: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TexasInstruments/tinyml-tensorlab/3a2d9e8eefdb3ee560d42aa8c01e31eeaf79f166/.gitmodules -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2023-2024, Texas Instruments Incorporated 2 | All Rights Reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | * Neither the name of the copyright holder nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 25 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /assets/mcu_ai_repo_connection.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TexasInstruments/tinyml-tensorlab/3a2d9e8eefdb3ee560d42aa8c01e31eeaf79f166/assets/mcu_ai_repo_connection.png -------------------------------------------------------------------------------- /git_pull_all.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Copyright (c) 2023-2024, Texas Instruments Incorporated 4 | # All Rights Reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are met: 8 | # 9 | # * Redistributions of source code must retain the above copyright notice, this 10 | # list of conditions and the following disclaimer. 11 | # 12 | # * Redistributions in binary form must reproduce the above copyright notice, 13 | # this list of conditions and the following disclaimer in the documentation 14 | # and/or other materials provided with the distribution. 15 | # 16 | # * Neither the name of the copyright holder nor the names of its 17 | # contributors may be used to endorse or promote products derived from 18 | # this software without specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | 32 | git pull --rebase 33 | 34 | git submodule init 35 | git submodule update 36 | -------------------------------------------------------------------------------- /scripts/git_update_all.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Copyright (c) 2023-2024, Texas Instruments Incorporated 4 | # All Rights Reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are met: 8 | # 9 | # * Redistributions of source code must retain the above copyright notice, this 10 | # list of conditions and the following disclaimer. 11 | # 12 | # * Redistributions in binary form must reproduce the above copyright notice, 13 | # this list of conditions and the following disclaimer in the documentation 14 | # and/or other materials provided with the distribution. 15 | # 16 | # * Neither the name of the copyright holder nor the names of its 17 | # contributors may be used to endorse or promote products derived from 18 | # this software without specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | 32 | git subtree pull --prefix tinyml-tinyverse ssh://git@bitbucket.itg.ti.com/tinyml-algo/tinyml-tinyverse.git main --squash 33 | git subtree pull --prefix tinyml-docs ssh://git@bitbucket.itg.ti.com/tinyml-algo/tinyml-docs.git main --squash 34 | git subtree pull --prefix tinyml-modeloptimization ssh://git@bitbucket.itg.ti.com/tinyml-algo/tinyml-modeloptimization.git main --squash 35 | git subtree pull --prefix tinyml-modelmaker ssh://git@bitbucket.itg.ti.com/tinyml-algo/tinyml-modelmaker.git main --squash 36 | git subtree pull --prefix tinyml-modelzoo ssh://git@bitbucket.itg.ti.com/tinyml-algo/tinyml-modelzoo.git main --squash 37 | 38 | git submodule update --remote 39 | -------------------------------------------------------------------------------- /tinyml-docs/README.md: -------------------------------------------------------------------------------- 1 | 2 | --- 3 | 4 | This page has moved. Please visit this new page for more information: https://github.com/TexasInstruments/edgeai 5 | 6 | --- 7 | -------------------------------------------------------------------------------- /tinyml-modelmaker/.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | data/labelstudio/ 3 | !data/labelstudio/readme.txt 4 | data/projects/ 5 | !data/projects/readme.txt 6 | data/downloads 7 | !data/downloads/readme.txt 8 | *.pyc 9 | *.egg-info/ 10 | .pkl_memoize_py3 11 | __pycache__/ 12 | build/ 13 | -------------------------------------------------------------------------------- /tinyml-modelmaker/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2023-2024, Texas Instruments Incorporated 2 | All Rights Reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | * Neither the name of the copyright holder nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 25 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /tinyml-modelmaker/config_byom_for_compilation.yaml: -------------------------------------------------------------------------------- 1 | common: # The common section can be plainly copied as it is 2 | target_module: 'timeseries' 3 | task_type: 'generic_timeseries_classification' 4 | target_device: 'F28P55' 5 | run_name: '{date-time}/{model_name}' 6 | 7 | dataset: 8 | enable: False # Please note the 'False'. This is important to disable data loading which is not important 9 | dataset_name: abc # Can be anything, used for directory name 10 | 11 | data_processing_feature_extraction: # Retain this information 12 | feature_extraction_name: None 13 | 14 | training: 15 | enable: False # Please note the 'False'. This is important to disable data loading which is not important 16 | model_name: 'a' # Can be anything, used for directory name 17 | 18 | compilation: 19 | enable: True 20 | model_path: "/x/y/z/model.onnx" # Most important: Path of the model to be compiled 21 | -------------------------------------------------------------------------------- /tinyml-modelmaker/config_timeseries_anomalydetection_ecg.yaml: -------------------------------------------------------------------------------- 1 | 2 | common: 3 | target_module: 'timeseries' 4 | task_type: 'generic_timeseries_anomalydetection' 5 | target_device: 'F28P55' 6 | run_name: '{date-time}/{model_name}' 7 | 8 | dataset: 9 | # enable/disable dataset loading 10 | enable: True 11 | dataset_name: ecg_ad 12 | input_data_path: /home/a0484689/PycharmProjects/tinyml_docker_images/ecg_dataset_ad/ 13 | # split_names: [training, validation] 14 | 15 | data_processing_feature_extraction: # One or more can be cascaded in the list 16 | # transforms: 'DownSample SimpleWindow' 17 | data_proc_transforms: [ Downsample, SimpleWindow ] 18 | # Downsample 19 | sampling_rate: 1 20 | new_sr: 1 21 | # SimpleWindow 22 | frame_size: 128 23 | stride_size: 1 24 | 25 | feat_ext_transform: [] 26 | variables: 1 27 | 28 | training: 29 | # enable/disable training 30 | enable: True #False 31 | # F28x generic timeseries model names: TimeSeries_Generic_1k_t, TimeSeries_Generic_4k_t, TimeSeries_Generic_6k_t, TimeSeries_Generic_13k_t 32 | # GUI only model names: ArcFault_model_200_t, ArcFault_model_300_t, ArcFault_model_700_t 33 | model_name: 'TimeSeries_Generic_AD_1k_t' 34 | # model_spec: '../tinyml-mlbackend/proprietary_models/cnn_af_3l.py' 35 | model_config: '' 36 | batch_size: 256 37 | training_epochs: 10 38 | num_gpus: 1 39 | optimizer: Adam 40 | learning_rate: 0.001 41 | 42 | testing: 43 | enable: True 44 | 45 | compilation: 46 | # enable/disable compilation 47 | enable: True #False 48 | # compile_preset_name: default_preset/forced_soft_npu_preset 49 | -------------------------------------------------------------------------------- /tinyml-modelmaker/config_timeseries_classification_dsi.yaml: -------------------------------------------------------------------------------- 1 | 2 | common: 3 | target_module: 'timeseries' 4 | task_type: 'arc_fault' 5 | target_device: 'F28P55' 6 | run_name: '{date-time}/{model_name}' 7 | dataset: 8 | # enable/disable dataset loading 9 | enable: True 10 | dataset_name: arc_fault_example_dsi 11 | # split_names: [training, validation] 12 | 13 | data_processing_feature_extraction: 14 | data_proc_transforms: [Downsample, SimpleWindow] 15 | # Downsample 16 | sampling_rate: 313000 17 | new_sr: 3130 18 | # SimpleWindow 19 | #sequence_window: 256 20 | frame_size: 256 21 | stride_size: 0.01 22 | 23 | variables: 1 24 | gof_test: False 25 | 26 | training: 27 | # enable/disable training 28 | enable: True #False 29 | # F28x generic timeseries model names: TimeSeries_Generic_1k_t, TimeSeries_Generic_4k_t, TimeSeries_Generic_6k_t, TimeSeries_Generic_13k_t 30 | # GUI only model names: ArcFault_model_200_t, ArcFault_model_300_t, ArcFault_model_700_t 31 | model_name: 'TimeSeries_Generic_13k_t' 32 | # model_spec: '../tinyml-mlbackend/proprietary_models/cnn_af_3l.py' 33 | model_config: '' 34 | batch_size: 2048 35 | training_epochs: 10 36 | num_gpus: 0 37 | 38 | testing: 39 | enable: True 40 | 41 | compilation: 42 | # enable/disable compilation 43 | enable: True #False 44 | # compile_preset_name: default_preset/forced_soft_npu_preset 45 | -------------------------------------------------------------------------------- /tinyml-modelmaker/config_timeseries_classification_dsk.yaml: -------------------------------------------------------------------------------- 1 | 2 | common: 3 | target_module: 'timeseries' 4 | task_type: 'arc_fault' 5 | target_device: 'F28P55' 6 | run_name: '{date-time}/{model_name}' 7 | # run_name: '20240710-191631' 8 | dataset: 9 | # enable/disable dataset loading 10 | enable: True #False 11 | dataset_name: arc_fault_example_dsk 12 | # input_data_path: '/home/a0484689/PycharmProjects/tinyml_docker_images/arc_fault_classification_dsk.zip' 13 | # split_type: within_files 14 | 15 | data_processing_feature_extraction: 16 | # One or more can be cascaded in the list 17 | # transforms: 'DownSample SimpleWindow' 18 | data_proc_transforms: [] 19 | # Downsample 20 | #sampling_rate: 313000 21 | #new_sr: 3130 22 | # SimpleWindow 23 | #frame_size: 256 24 | #stride_size: 0.01 25 | 26 | feature_extraction_name: FFT1024Input_256Feature_1Frame_Full_Bandwidth 27 | # feature_extraction_name: FFT1024Input_256Feature_1Frame_Half_Bandwidth 28 | # feature_extraction_name: FFT1024Input_64Feature_4Frame_Half_Bandwidth 29 | # feature_extraction_name: FFT1024Input_32Feature_8Frame_Quarter_Bandwidth 30 | # feature_extraction_name: Custom_ArcFault 31 | # feat_ext_transform: [] 32 | # frame_size: 1024 33 | # feature_size_per_frame: 128 34 | # num_frame_concat: 1 35 | # min_bin: 4 36 | # analysis_bandwidth: 1 37 | # frame_skip: 1 38 | # store_feat_ext_data: False 39 | # nn_for_feature_extraction: True 40 | variables: 1 41 | 42 | training: 43 | # enable/disable training 44 | enable: True #False 45 | # F28x generic timeseries model names: TimeSeries_Generic_1k_t, TimeSeries_Generic_4k_t, TimeSeries_Generic_6k_t, TimeSeries_Generic_13k_t 46 | # GUI only model names: ArcFault_model_200_t, ArcFault_model_300_t, ArcFault_model_700_t, ArcFault_model_1400_t 47 | model_name: 'TimeSeries_Generic_1k_t' 48 | # with_input_batchnorm: False 49 | # model_spec: '../tinyml-mlbackend/proprietary_models/cnn_af_3l.py' 50 | model_config: '' 51 | batch_size: 32 52 | training_epochs: 10 53 | num_gpus: 0 54 | # quantization_method: 'QAT' # QAT/PTQ 55 | # quantization_weight_bitwidth: 2 56 | # quantization_activation_bitwidth: 8 57 | # augment_config: 'misc/augmenter_config.yaml' 58 | # quantization: 2 59 | 60 | testing: 61 | enable: True 62 | skip_train: False # True if only the model needs to be tested (BYOM for testing). model_path below needs to be given 63 | # model_path: Onnx/tflite Model Path for BYOM for compilation only 64 | # test_data: ./data/projects/arc_fault_example_dsk/dataset/classes # if dataset is being provided here then- dataset-> enable: False 65 | 66 | 67 | compilation: 68 | # enable/disable compilation 69 | enable: True #False 70 | # No preset is required for devices other than F28P55 71 | # preset_name: default_preset/ forced_soft_npu_preset 72 | # compile_preset_name: forced_soft_npu_preset 73 | -------------------------------------------------------------------------------- /tinyml-modelmaker/config_timeseries_classification_ecg.yaml: -------------------------------------------------------------------------------- 1 | 2 | common: 3 | target_module: 'timeseries' 4 | task_type: 'generic_timeseries_classification' 5 | target_device: 'F28P55' 6 | run_name: '{date-time}/{model_name}' 7 | dataset: 8 | # enable/disable dataset loading 9 | enable: True 10 | dataset_name: ecg 11 | input_data_path: /home/a0484689/PycharmProjects/tinyml_docker_images/ecg_dataset/ 12 | # split_names: [training, validation] 13 | 14 | data_processing_feature_extraction: 15 | # One or more can be cascaded in the list 16 | # transforms: 'DownSample SimpleWindow' 17 | data_proc_transforms: [ Downsample, SimpleWindow ] 18 | # Downsample 19 | sampling_rate: 1 20 | new_sr: 1 21 | # SimpleWindow 22 | frame_size: 128 23 | stride_size: 1 24 | 25 | feat_ext_transform: [] 26 | variables: 1 27 | 28 | training: 29 | # enable/disable training 30 | enable: True #False 31 | # F28x generic timeseries model names: TimeSeries_Generic_1k_t, TimeSeries_Generic_4k_t, TimeSeries_Generic_6k_t, TimeSeries_Generic_13k_t 32 | # GUI only model names: ArcFault_model_200_t, ArcFault_model_300_t, ArcFault_model_700_t 33 | model_name: 'TimeSeries_Generic_4k_t' 34 | # model_spec: '../tinyml-mlbackend/proprietary_models/cnn_af_3l.py' 35 | model_config: '' 36 | batch_size: 256 37 | training_epochs: 50 38 | num_gpus: 0 39 | 40 | testing: 41 | enable: True 42 | 43 | compilation: 44 | # enable/disable compilation 45 | enable: True #False 46 | # compile_preset_name: default_preset/forced_soft_npu_preset 47 | -------------------------------------------------------------------------------- /tinyml-modelmaker/config_timeseries_classification_fan_blade_dsi.yaml: -------------------------------------------------------------------------------- 1 | 2 | common: 3 | target_module: 'timeseries' 4 | task_type: 'motor_fault' 5 | target_device: 'F28P55' 6 | run_name: '{date-time}/{model_name}' 7 | dataset: 8 | # enable/disable dataset loading 9 | enable: True #False 10 | dataset_name: fan_blade_fault 11 | input_data_path: http://software-dl.ti.com/C2000/esd/mcu_ai/01_00_00/datasets/fan_blade_fault_dsi.zip 12 | 13 | data_processing_feature_extraction: # One or more can be cascaded in the list 14 | data_proc_transforms: [] 15 | # feature_extraction_name: MotorFault_256Input_FFTBIN_16Feature_8Frame_3InputChannel_removeDC_1D 16 | feature_extraction_name: MotorFault_256Input_FFTBIN_16Feature_8Frame_3InputChannel_removeDC_2D1 17 | # feature_extraction_name: MotorFault_256Input_FFT_128Feature_1Frame_3InputChannel_removeDC_2D1 18 | # feature_extraction_name: MotorFault_128Input_RAW_128Feature_1Frame_3InputChannel_removeDC_2D1 19 | # feature_extraction_name: Custom_MotorFault 20 | # frame_size: 256 21 | # feature_size_per_frame: 128 22 | # num_frame_concat: 8 23 | # normalize_bin: 1 24 | # stacking: 2D1 25 | # feat_ext_transform: ['FFT_FE', 'FFT_POS_HALF', 'DC_REMOVE', 'ABS', 'LOG_DB', 'CONCAT'] 26 | # offset: 0 27 | # scale: 1 28 | # frame_skip: 1 29 | # log_mul: 20 30 | # log_base: 10 31 | # log_threshold: 1e-100 32 | # store_feat_ext_data: False 33 | # nn_for_feature_extraction: False 34 | variables: 3 35 | 36 | training: 37 | # enable/disable training 38 | enable: True #False 39 | # F28x generic timeseries model names: TimeSeries_Generic_1k_t, TimeSeries_Generic_4k_t, TimeSeries_Generic_6k_t, TimeSeries_Generic_13k_t 40 | # GUI only model names: MotorFault_model_1_t, MotorFault_model_2_t, MotorFault_model_3_t 41 | model_name: 'TimeSeries_Generic_4k_t' 42 | # model_spec: '../tinyml-mlbackend/proprietary_models/cnn_mf_1l.py' 43 | model_config: '' 44 | batch_size: 256 45 | training_epochs: 20 46 | num_gpus: 1 # 1 47 | # learning_rate: 0.001 48 | 49 | testing: 50 | enable: True 51 | 52 | compilation: 53 | # enable/disable compilation 54 | enable: True #False 55 | # No preset is required for devices other than F28P55 56 | # compile_preset_name: forced_soft_npu_preset 57 | -------------------------------------------------------------------------------- /tinyml-modelmaker/config_timeseries_classification_fan_blower_imbalance_dsh.yaml: -------------------------------------------------------------------------------- 1 | 2 | common: 3 | target_module: 'timeseries' 4 | task_type: 'motor_fault' 5 | target_device: 'F28P55' 6 | run_name: '{date-time}/{model_name}' 7 | dataset: 8 | # enable/disable dataset loading 9 | enable: True #False 10 | dataset_name: fan_blower_imbalance_dsh 11 | 12 | data_processing_feature_extraction: # One or more can be cascaded in the list 13 | data_proc_transforms: [] 14 | # feature_extraction_name: MotorFault_256Input_FFTBIN_16Feature_8Frame_3InputChannel_removeDC_1D 15 | feature_extraction_name: MotorFault_256Input_FFTBIN_16Feature_8Frame_3InputChannel_removeDC_2D1 16 | # feature_extraction_name: MotorFault_256Input_FFT_128Feature_1Frame_3InputChannel_removeDC_2D1 17 | # feature_extraction_name: MotorFault_128Input_RAW_128Feature_1Frame_3InputChannel_removeDC_2D1 18 | # feature_extraction_name: Custom_MotorFault 19 | # frame_size: 256 20 | # feature_size_per_frame: 128 21 | # num_frame_concat: 8 22 | # normalize_bin: 1 23 | # stacking: 2D1 24 | # feat_ext_transform: ['FFT_FE', 'FFT_POS_HALF', 'DC_REMOVE', 'ABS', 'LOG_DB', 'CONCAT'] 25 | # offset: 0 26 | # scale: 1 27 | # frame_skip: 1 28 | # log_mul: 20 29 | # log_base: 10 30 | # log_threshold: 1e-100 31 | # store_feat_ext_data: False 32 | # nn_for_feature_extraction: False 33 | variables: 3 34 | 35 | 36 | 37 | 38 | training: 39 | # enable/disable training 40 | enable: True #False 41 | # F28x generic timeseries model names: TimeSeries_Generic_1k_t, TimeSeries_Generic_4k_t, TimeSeries_Generic_6k_t, TimeSeries_Generic_13k_t 42 | # GUI only model names: MotorFault_model_1_t, MotorFault_model_2_t, MotorFault_model_3_t 43 | model_name: 'MotorFault_model_2_t' 44 | # model_spec: '../tinyml-mlbackend/proprietary_models/cnn_mf_1l.py' 45 | model_config: '' 46 | batch_size: 256 47 | training_epochs: 20 48 | num_gpus: 1 # 1 49 | # learning_rate: 0.001 50 | 51 | testing: 52 | enable: True 53 | 54 | compilation: 55 | # enable/disable compilation 56 | enable: True #False 57 | # No preset is required for devices other than F28P55 58 | # compile_preset_name: forced_soft_npu_preset 59 | -------------------------------------------------------------------------------- /tinyml-modelmaker/config_timeseries_classification_helloworld_dsg.yaml: -------------------------------------------------------------------------------- 1 | 2 | common: 3 | target_module: 'timeseries' 4 | task_type: 'generic_timeseries_classification' 5 | target_device: 'F28P55' 6 | run_name: '{date-time}/{model_name}' 7 | dataset: 8 | # enable/disable dataset loading 9 | enable: True #False 10 | dataset_name: hello_world_example_dsg 11 | # input_data_path: http://software-dl.ti.com/C2000/esd/mcu_ai/01_00_00/datasets/hello_world_dsg.zip 12 | # split_type: within_files 13 | # gof_test: True 14 | 15 | 16 | data_processing_feature_extraction: 17 | feature_extraction_name: Generic_1024Input_FFTBIN_64Feature_8Frame 18 | # feature_extraction_name: Generic_512Input_FFTBIN_32Feature_8Frame 19 | # feature_extraction_name: Generic_256Input_FFTBIN_16Feature_8Frame 20 | # feature_extraction_name: Generic_1024Input_FFT_512Feature_1Frame 21 | # feature_extraction_name: Generic_512Input_FFT_256Feature_1Frame 22 | # feature_extraction_name: Generic_256Input_FFT_128Feature_1Frame 23 | # feature_extraction_name: Generic_512Input_RAW_512Feature_1Frame 24 | # feature_extraction_name: Generic_256Input_RAW_256Feature_1Frame 25 | # feature_extraction_name: Generic_128Input_RAW_128Feature_1Frame 26 | 27 | variables: 1 28 | # frame_size: 1024 29 | # feature_size_per_frame: 64 30 | # num_frame_concat: 4 31 | # feat_ext_transform: ['FFT_FE', 'FFT_POS_HALF', 'DC_REMOVE', 'ABS', 'BINNING', 'LOG_DB', 'CONCAT'] 32 | # offset: 0 33 | # scale: 1 34 | # frame_skip: 1 35 | # log_mul: 20 36 | # log_base: 10 37 | # log_threshold: 1e-100 38 | # store_feat_ext_data: False 39 | # nn_for_feature_extraction: False 40 | 41 | training: 42 | # enable/disable training 43 | enable: True #False 44 | # F28x generic timeseries model names: TimeSeries_Generic_1k_t, TimeSeries_Generic_4k_t, TimeSeries_Generic_6k_t, TimeSeries_Generic_13k_t 45 | model_name: 'TimeSeries_Generic_13k_t' 46 | # model_spec: '' 47 | batch_size: 256 48 | training_epochs: 20 49 | num_gpus: 0 50 | # learning_rate: 0.001 51 | 52 | testing: 53 | enable: True 54 | 55 | compilation: 56 | # enable/disable compilation 57 | enable: True #False 58 | -------------------------------------------------------------------------------- /tinyml-modelmaker/config_timeseries_classification_motor_bearing_dsk.yaml: -------------------------------------------------------------------------------- 1 | common: 2 | target_module: 'timeseries' 3 | task_type: 'motor_fault' 4 | target_device: 'F28P55' 5 | run_name: '{date-time}/{model_name}' 6 | 7 | dataset: 8 | # enable/disable dataset loading 9 | enable: True #False 10 | dataset_name: 'motor_fault_example_dsk' 11 | 12 | data_processing_feature_extraction: 13 | # feature_extraction_name: 'MotorFault_256Input_FFTBIN_16Feature_8Frame_3InputChannel_removeDC_1D' 14 | # feature_extraction_name: MotorFault_256Input_FFTBIN_16Feature_8Frame_3InputChannel_removeDC_1D 15 | # feature_extraction_name: MotorFault_256Input_FFTBIN_16Feature_8Frame_3InputChannel_removeDC_2D1 16 | # feature_extraction_name: MotorFault_256Input_FFT_128Feature_1Frame_3InputChannel_removeDC_2D1 17 | feature_extraction_name: 'Custom_MotorFault' 18 | frame_size: 1024 19 | feature_size_per_frame: 64 20 | num_frame_concat: 4 21 | normalize_bin: 1 22 | stacking: 1D 23 | feat_ext_transform: [ 'FFT_FE', 'FFT_POS_HALF', 'DC_REMOVE', 'ABS', 'BINNING', 'LOG_DB', 'CONCAT' ] 24 | offset: 0 25 | scale: 1 26 | frame_skip: 1 27 | log_mul: 20 28 | log_base: 10 29 | log_threshold: 1e-100 30 | # store_feat_ext_data: False 31 | # nn_for_feature_extraction: False 32 | gof_test: False 33 | variables: 3 34 | 35 | training: 36 | # enable/disable training 37 | enable: True #False 38 | # F28x generic timeseries model names: TimeSeries_Generic_1k_t, TimeSeries_Generic_4k_t, TimeSeries_Generic_6k_t, TimeSeries_Generic_13k_t 39 | # GUI only model names: MotorFault_model_1_t, MotorFault_model_2_t, MotorFault_model_3_t 40 | model_name: 'TimeSeries_Generic_1k_t' 41 | # model_spec: '../tinyml-mlbackend/proprietary_models/cnn_mf_1l.py' 42 | model_config: '' 43 | batch_size: 256 44 | training_epochs: 20 45 | num_gpus: 1 46 | # learning_rate: 0.001 47 | 48 | testing: 49 | enable: True 50 | 51 | compilation: 52 | # enable/disable compilation 53 | enable: True #False 54 | # No preset is required for devices other than F28P55 55 | # compile_preset_name: forced_soft_npu_preset 56 | -------------------------------------------------------------------------------- /tinyml-modelmaker/config_timeseries_regression_dsi.yaml: -------------------------------------------------------------------------------- 1 | 2 | common: 3 | target_module: 'timeseries' 4 | task_type: 'generic_timeseries_regression' 5 | target_device: 'F28P55' 6 | run_name: '{date-time}/{model_name}' 7 | 8 | dataset: 9 | # enable/disable dataset loading 10 | enable: True 11 | data_dir: 'files' 12 | dataset_name: battery_dataset 13 | input_data_path: '/home/a0484689/PycharmProjects/tinyml_docker_images/battery_dataset/' 14 | # split_names: [training, validation] 15 | 16 | data_processing_feature_extraction: # One or more can be cascaded in the list 17 | # transforms: 'DownSample SimpleWindow' 18 | data_proc_transforms: [] 19 | # Downsample 20 | #sampling_rate: 1 21 | #new_sr: 1 22 | # SimpleWindow 23 | #frame_size: 16 24 | #stride_size: 1 25 | feat_ext_transform: ['FFT_FE', 'FFT_POS_HALF', 'DC_REMOVE', 'ABS', 'BINNING', 'LOG_DB', 'CONCAT'] 26 | frame_size: 16 27 | feature_size_per_frame: 4 28 | num_frame_concat: 4 29 | normalize_bin: 1 30 | stacking: 1D 31 | offset: 0 32 | scale: 1 33 | frame_skip: 1 34 | log_mul: 20 35 | log_base: 10 36 | log_threshold: 1e-100 37 | variables: 5 38 | 39 | training: 40 | # enable/disable training 41 | enable: True #False 42 | # optimizer: 'adam' 43 | # F28x generic timeseries model names: TimeSeries_Generic_1k_t, TimeSeries_Generic_4k_t, TimeSeries_Generic_6k_t, TimeSeries_Generic_13k_t 44 | # GUI only model names: ArcFault_model_200_t, ArcFault_model_300_t, ArcFault_model_700_t 45 | model_name: 'TimeSeries_Generic_Regr_3k_t' 46 | # model_spec: '../tinyml-mlbackend/proprietary_models/cnn_af_3l.py' 47 | model_config: '' 48 | batch_size: 256 49 | training_epochs: 50 50 | num_gpus: 0 51 | quantization: 2 52 | 53 | testing: 54 | enable: True 55 | 56 | compilation: 57 | # enable/disable compilation 58 | enable: True #False 59 | # compile_preset_name: default_preset/forced_soft_npu_preset 60 | -------------------------------------------------------------------------------- /tinyml-modelmaker/data/descriptions/readme.txt: -------------------------------------------------------------------------------- 1 | ai module descriptions will be written here. 2 | -------------------------------------------------------------------------------- /tinyml-modelmaker/docker/docker_build.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ################################################################################# 4 | # Copyright (c) 2018-2022, Texas Instruments Incorporated - http://www.ti.com 5 | # All Rights Reserved. 6 | # 7 | # Redistribution and use in source and binary forms, with or without 8 | # modification, are permitted provided that the following conditions are met: 9 | # 10 | # * Redistributions of source code must retain the above copyright notice, this 11 | # list of conditions and the following disclaimer. 12 | # 13 | # * Redistributions in binary form must reproduce the above copyright notice, 14 | # this list of conditions and the following disclaimer in the documentation 15 | # and/or other materials provided with the distribution. 16 | # 17 | # * Neither the name of the copyright holder nor the names of its 18 | # contributors may be used to endorse or promote products derived from 19 | # this software without specific prior written permission. 20 | # 21 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 25 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 28 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | # 32 | ################################################################################# 33 | 34 | DOCKER_IMAGE_NAME="tinyml-modelmaker:1.0.0" 35 | 36 | ################################################################################# 37 | USE_INTERNAL_REPO="1" 38 | 39 | # docker and git repo locations - internal or external build 40 | if [[ ${USE_INTERNAL_REPO} == "1" ]]; then 41 | DOCKER_REPO_LOCATION="artifactory.itg.ti.com/docker-public/library/" 42 | SOURCE_LOCATION="ssh://git@bitbucket.itg.ti.com/tinyml-algo/" 43 | else 44 | DOCKER_REPO_LOCATION="" 45 | SOURCE_LOCATION="https://github.com/TexasInstruments/" 46 | fi 47 | 48 | # initialize http_proxy and https_proxy if they are not defined 49 | http_proxy=${http_proxy:-""} 50 | https_proxy=${https_proxy:-""} 51 | no_proxy=${no_proxy:-""} 52 | 53 | ################################################################################# 54 | # Build docker image 55 | echo "building docker image..." 56 | docker build \ 57 | -f ./docker/Dockerfile \ 58 | -t ${DOCKER_IMAGE_NAME} \ 59 | --build-arg DOCKER_REPO_LOCATION=${DOCKER_REPO_LOCATION} \ 60 | --build-arg http_proxy=${http_proxy} \ 61 | --build-arg https_proxy=${https_proxy} \ 62 | --build-arg no_proxy=${no_proxy} \ 63 | --no-cache . 64 | -------------------------------------------------------------------------------- /tinyml-modelmaker/docker/docker_run.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ################################################################################# 4 | # Copyright (c) 2018-2022, Texas Instruments Incorporated - http://www.ti.com 5 | # All Rights Reserved. 6 | # 7 | # Redistribution and use in source and binary forms, with or without 8 | # modification, are permitted provided that the following conditions are met: 9 | # 10 | # * Redistributions of source code must retain the above copyright notice, this 11 | # list of conditions and the following disclaimer. 12 | # 13 | # * Redistributions in binary form must reproduce the above copyright notice, 14 | # this list of conditions and the following disclaimer in the documentation 15 | # and/or other materials provided with the distribution. 16 | # 17 | # * Neither the name of the copyright holder nor the names of its 18 | # contributors may be used to endorse or promote products derived from 19 | # this software without specific prior written permission. 20 | # 21 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 25 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 28 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | # 32 | ################################################################################# 33 | 34 | docker_image_name="tinyml-modelmaker:1.0.0" 35 | docker_container_name="cnt-tinyml-modelmaker:1.0.0" 36 | PARENT_DIR=$(realpath ..) 37 | 38 | # initialize http_proxy and https_proxy if they are not defined 39 | http_proxy=${http_proxy:-""} 40 | https_proxy=${https_proxy:-""} 41 | no_proxy=${no_proxy:-""} 42 | 43 | # Number of containers existing with the given name 44 | container_count=$(docker ps -a | grep ${docker_container_name} | wc -l) 45 | echo "Number of containers with the given name/tag: ${container_count} " 46 | 47 | if [ $container_count -eq 0 ] 48 | then 49 | echo "Starting a new container: ${docker_container_name}" 50 | docker run -it \ 51 | --name "${docker_container_name}" \ 52 | -v ${PARENT_DIR}:/opt/code \ 53 | --privileged \ 54 | --network host \ 55 | --shm-size 25G \ 56 | -e http_proxy=${http_proxy} \ 57 | -e https_proxy=${https_proxy} \ 58 | -e no_proxy=${no_proxy} \ 59 | --user $(id -u):$(id -g) \ 60 | ${docker_image_name} bash 61 | elif [ $container_count -eq 1 ] 62 | then 63 | echo "Restarting existing container: ${docker_container_name}" 64 | docker start "${docker_container_name}" 65 | docker exec -it "${docker_container_name}" /bin/bash 66 | else 67 | echo -e "\nMultiple containers found with similar name/tag ${docker_container_name}, so exiting" 68 | echo -e "To run existing container, use [docker start] and [docker exec] command" 69 | echo -e "To run the new container, use [docker run] command\n" 70 | fi 71 | -------------------------------------------------------------------------------- /tinyml-modelmaker/docker/docker_setup.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Copyright (c) 2018-2021, Texas Instruments 4 | # All Rights Reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are met: 8 | # 9 | # * Redistributions of source code must retain the above copyright notice, this 10 | # list of conditions and the following disclaimer. 11 | # 12 | # * Redistributions in binary form must reproduce the above copyright notice, 13 | # this list of conditions and the following disclaimer in the documentation 14 | # and/or other materials provided with the distribution. 15 | # 16 | # * Neither the name of the copyright holder nor the names of its 17 | # contributors may be used to endorse or promote products derived from 18 | # this software without specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | ###################################################################### 32 | 33 | sudo apt update 34 | sudo apt install docker.io 35 | sudo usermod -aG docker ${USER} 36 | sudo systemctl start docker 37 | sudo systemctl enable docker 38 | # logout and log back in and docker should be ready to use. 39 | -------------------------------------------------------------------------------- /tinyml-modelmaker/docker/proxy_setup.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ################################################################################# 4 | # Copyright (c) 2018-2022, Texas Instruments Incorporated - http://www.ti.com 5 | # All Rights Reserved. 6 | # 7 | # Redistribution and use in source and binary forms, with or without 8 | # modification, are permitted provided that the following conditions are met: 9 | # 10 | # * Redistributions of source code must retain the above copyright notice, this 11 | # list of conditions and the following disclaimer. 12 | # 13 | # * Redistributions in binary form must reproduce the above copyright notice, 14 | # this list of conditions and the following disclaimer in the documentation 15 | # and/or other materials provided with the distribution. 16 | # 17 | # * Neither the name of the copyright holder nor the names of its 18 | # contributors may be used to endorse or promote products derived from 19 | # this software without specific prior written permission. 20 | # 21 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 25 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 28 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | # 32 | ################################################################################# 33 | 34 | # initialize http_proxy and https_proxy if they are not defined 35 | http_proxy=${http_proxy:-""} 36 | https_proxy=${https_proxy:-""} 37 | no_proxy=${no_proxy:-""} 38 | 39 | 40 | # proxy for apt 41 | if [ ! -z ${http_proxy} ]; then 42 | echo "Acquire::http::proxy \"${http_proxy}\";" > /etc/apt/apt.conf; 43 | fi 44 | 45 | if [ ! -z ${https_proxy} ]; then 46 | echo "Acquire::https::proxy \"${https_proxy}\";" >> /etc/apt/apt.conf; 47 | fi 48 | -------------------------------------------------------------------------------- /tinyml-modelmaker/docker/readme.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TexasInstruments/tinyml-tensorlab/3a2d9e8eefdb3ee560d42aa8c01e31eeaf79f166/tinyml-modelmaker/docker/readme.txt -------------------------------------------------------------------------------- /tinyml-modelmaker/docs/AddingFeatureExtractors.md: -------------------------------------------------------------------------------- 1 | # Guide to add feature extractors 2 | 3 | ### To add a feature extractor, the following guide will help you 4 | - The feature extractor needs to be added to TinyVerse 5 | - Say for example, to add a feature extractor for audio tasks 6 | - Head over to `/tinyml-tinyverse/tinyml_tinyverse/common/transforms` 7 | - In the directory, add a `.py` file 8 | - and import the corresponding feature extractor name to `common/datasets/timeseries_dataset.py` and use it correspondingly in the data loader. 9 | 10 | --- 11 | #### At this stage, the TinyVerse package can function independently with the feature extractor 12 | -------------------------------------------------------------------------------- /tinyml-modelmaker/docs/AddingModalities.md: -------------------------------------------------------------------------------- 1 | # Guide to add modalities 2 | 3 | ### To add a modality, the following guide will help you 4 | By the term modality, we mean an additional `ai_module` present under [./tinyml-modelmaker/tinyml_modelmaker/ai_modules/](../tinyml_modelmaker/ai_modules/) such as 5 | - `audio` 6 | - `timeseries` 7 | - `vision` 8 | - `another_modality` and so on 9 | 10 | ### Each modality must have 3 subparts mandatorily 11 | - `datasets` 12 | - `training` 13 | - `compilation` 14 | 15 | #### The directory structure of a modality will look like this: 16 | In `../tinyml_modelmaker/ai_modules/timeseries/` : 17 | * [\_\_init__.py](../tinyml_modelmaker/ai_modules/timeseries/\_\_init__.py) - Contains all the imports from the subsequent files 18 | * #### [datasets](../tinyml_modelmaker/ai_modules/timeseries/datasets) 19 | * [\_\_init__.py](../tinyml_modelmaker/ai_modules/timeseries/datasets/\_\_init__.py) 20 | * #### [training](../tinyml_modelmaker/ai_modules/timeseries/training) 21 | * [\_\_init__.py](../tinyml_modelmaker/ai_modules/timeseries/training/\_\_init__.py) 22 | * #### [tinyml_tinyverse](../tinyml_modelmaker/ai_modules/timeseries/training/tinyml_tinyverse) 23 | * [\_\_init__.py](../tinyml_modelmaker/ai_modules/timeseries/training/tinyml_tinyverse/\_\_init__.py) 24 | * [classification.py](../tinyml_modelmaker/ai_modules/timeseries/training/tinyml_tinyverse/timeseries_classification.py) - This is the `task_name.py`. Similarly we can have `regression.py` and so on. 25 | * #### [compilation](../tinyml_modelmaker/ai_modules/timeseries/compilation) 26 | * [\_\_init__.py](../tinyml_modelmaker/ai_modules/timeseries/compilation/\_\_init__.py) 27 | * [constants.py](../tinyml_modelmaker/ai_modules/timeseries/constants.py) 28 | * [descriptions.py](../tinyml_modelmaker/ai_modules/timeseries/descriptions.py) 29 | * [params.py](../tinyml_modelmaker/ai_modules/timeseries/params.py) - Contains the parameters required for dataset, training and compilation tasks from the configuration.yaml file 30 | * [runner.py](../tinyml_modelmaker/ai_modules/timeseries/runner.py) - The core engine that runs the flow based on config file 31 | 32 | ### Please Note: 33 | - Unless necessary, the `__init__.py` under `datasets` , `training` and `compilation` could contain just the same contents as other modalities like audio or timeseries 34 | 35 | ## Changes in `tinyml-tinyverse` 36 | - An equivalent update in directory of the tinyverse repo needs to happen 37 | - Subsequent folders and files as per needed belonging to either/or more of `transforms`, `datasets`, `models`, `compilations` or `utils` should be added 38 | 39 | 40 | -------------------------------------------------------------------------------- /tinyml-modelmaker/docs/AddingModels.md: -------------------------------------------------------------------------------- 1 | # Guide to add models 2 | 3 | ### To add a model, the following guide will help you 4 | - The model needs to be added to TinyVerse 5 | - Say for example, to add a model for audio tasks 6 | - Head over to `/tinyml-tinyverse/tinyml_tinyverse/common/models` 7 | - In the directory, add a `.py` file or add the model to any of the existing `generic_*_models.py` 8 | - and add the corresponding model name to `__init__.py` in the `model_dict` 9 | 10 | --- 11 | #### At this stage, the TinyVerse package can function independently with the model 12 | 13 | --- 14 | #### However, to make sure the Modelmaker also can run the model, we need to add a few more files 15 | 16 | - Head over to `/tinyml-modelmaker/tinyml_modelmaker/ai_modules/common/timeseries/training/tinyml_tinyverse/` 17 | - Note: In the above path `timeseries` needs to be replaced with the respective ai_module, i.e `audio` or `vision` etc 18 | - In case the added model is for a classification task, then go to the script: Eg.: `timeseries_classification.py` 19 | - Add the model details under `model_urls`, `_model_descriptions` and `enabled_models_list` -------------------------------------------------------------------------------- /tinyml-modelmaker/docs/BYOM_for_Compilation.md: -------------------------------------------------------------------------------- 1 | # Bring Your Own Model (BYOM) for Compilation 2 | 3 | If you have your own AI Model Training Framework but you want to compile your .onnx/.tflite model for TI MCUs, then you can use Tiny ML Modelmaker for this purpose. 4 | 5 | The only change is that the config.yaml that you use will have to look something like below: 6 | ```python 7 | common: # The common section can be plainly copied as it is 8 | target_module: 'timeseries' 9 | task_type: 'generic_timeseries_classification' 10 | target_device: 'F28P55' 11 | run_name: '{date-time}/{model_name}' 12 | dataset: 13 | enable: False # Please note the 'False'. This is important to disable data loading which is not important 14 | dataset_name: abc # Can be anything, used for directory name 15 | feature_extraction: # Retain this information 16 | feature_extraction_name: None 17 | training: 18 | enable: False # Please note the 'False'. This is important to disable data loading which is not important 19 | model_name: 'a' # Can be anything, used for directory name 20 | compilation: 21 | enable: True 22 | model_path: "/x/y/z/model.onnx" # Most important: Path of the model to be compiled 23 | ``` 24 | The last line of the above file is where you specify the model to be compiled. 25 | 26 | Then, you can run the following using [config_byom_for_compilation.yaml](..%2Fconfig_byom_for_compilation.yaml) 27 | ``` 28 | run_tinyml_modelmaker.sh 29 | 30 | Example: 31 | run_tinyml_modelmaker.sh F28P55 config_byom_for_compilation.yaml 32 | ``` 33 | -------------------------------------------------------------------------------- /tinyml-modelmaker/docs/Configuring_Model_layer_params.md: -------------------------------------------------------------------------------- 1 | # Configure the model layers 2 | 3 | * This is a guide on configuring the model's input arguments. 4 | * Called the model_config, examples can be found inside the [misc](../misc) folder. 5 | * To use this, you need to provide the path of the local `model_config` in the `config_*_*.yaml` under the `training` subsection. 6 | * Example: 7 | * In [config_timeseries_classification_dsi.yaml](../config_timeseries_classification_dsi.yaml) 8 | * Under training section: 9 | ```yaml 10 | training: 11 | enable: True 12 | model_name: 'TimeSeries_Generic_13k_t' 13 | model_config: '/home/a/b/tinyml-modelmaker/misc/TimeSeries_Generic_x_t.yaml' 14 | ``` 15 | 16 | * The contents of the yaml file needs to have the parameters that the model accepts as an input argument 17 | * For example, the class definition of CNN_TS_GEN_BASE_13K (which is referred to by TimeSeries_Generic_13k_t) contains the following input arguments: 18 | * input_features, variables, num_classes, with_input_batchnorm 19 | ```python 20 | class CNN_TS_GEN_BASE_13K(GenericModelWithSpec): 21 | def __init__(self, config, input_features=512, variables=1, num_classes=2, with_input_batchnorm=True): 22 | ``` 23 | 24 | * So we can have (none or upto) the following arguments in `/home/a/b/tinyml-modelmaker/misc/TimeSeries_Generic_13k_t.yaml` 25 | ```yaml 26 | input_features: 512 27 | variables: 2 28 | num_classes: 3 29 | with_input_batchnorm: False 30 | ``` 31 | 32 | * This will edit the model properties accordingly 33 | * Kindly see more examples in [misc](../misc) folder. 34 | -------------------------------------------------------------------------------- /tinyml-modelmaker/docs/LabelStudioJSONFormat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TexasInstruments/tinyml-tensorlab/3a2d9e8eefdb3ee560d42aa8c01e31eeaf79f166/tinyml-modelmaker/docs/LabelStudioJSONFormat.png -------------------------------------------------------------------------------- /tinyml-modelmaker/examples/branched_model_parameters/config_timeseries_classification_wisdm.yaml: -------------------------------------------------------------------------------- 1 | 2 | common: 3 | target_module: 'timeseries' 4 | task_type: 'generic_timeseries_classification' 5 | target_device: 'F28P55' 6 | run_name: '{date-time}/{model_name}' 7 | 8 | dataset: 9 | # enable/disable dataset loading 10 | enable: True #False 11 | dataset_name: wisdm_example 12 | input_data_path: 'examples/branched_model_parameters/wisdm_dataset.zip' 13 | 14 | data_processing: # One or more can be cascaded in the list 15 | # transforms: 'DownSample SimpleWindow' 16 | transforms: [SimpleWindow] 17 | # Downsample 18 | sampling_rate: 313000 19 | new_sr: 3130 20 | # SimpleWindow 21 | sequence_window: 128 22 | stride_size: 0.01 23 | variables: 3 24 | 25 | feature_extraction: 26 | feature_extraction_name: Custom_Default 27 | transform: [] 28 | store_feat_ext_data: False 29 | 30 | training: 31 | # enable/disable training 32 | enable: True #False 33 | model_name: 'Res_TimeSeries_Generic_3k_t' 34 | model_config: 'examples/branched_model_parameters/residual_network_config.yaml' 35 | batch_size: 32 36 | training_epochs: 10 37 | num_gpus: 0 38 | 39 | testing: 40 | enable: True 41 | skip_train: False # True 42 | 43 | compilation: 44 | # enable/disable compilation 45 | enable: True #False -------------------------------------------------------------------------------- /tinyml-modelmaker/examples/branched_model_parameters/readme/model.onnx.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TexasInstruments/tinyml-tensorlab/3a2d9e8eefdb3ee560d42aa8c01e31eeaf79f166/tinyml-modelmaker/examples/branched_model_parameters/readme/model.onnx.png -------------------------------------------------------------------------------- /tinyml-modelmaker/examples/branched_model_parameters/residual_network_config.yaml: -------------------------------------------------------------------------------- 1 | out_channel_layer1: 8 2 | out_channel_layer2: 16 3 | out_channel_layer3: 32 4 | with_input_batchnorm: True -------------------------------------------------------------------------------- /tinyml-modelmaker/examples/branched_model_parameters/wisdm.py: -------------------------------------------------------------------------------- 1 | import os 2 | import requests as re 3 | 4 | import pandas as pd 5 | 6 | url = "https://www.cis.fordham.edu/wisdm/includes/datasets/latest/WISDM_ar_latest.tar.gz" 7 | 8 | DOWNLOADED_ZIP_FILE_NAME = "WISDM_ar_latest.tar.gz" 9 | EXTRACTED_FOLDER_NAME = "WISDM_ar_v1.1" 10 | RAW_DATA_FILE_NAME = "WISDM_ar_v1.1_raw.txt" 11 | NUM_SPLITS = 5 12 | 13 | FILE_NAME = "wisdm_dataset.csv" 14 | CREATED_ZIP_FILE_NAME = "wisdm_dataset.zip" 15 | 16 | def download_data(): 17 | print("Downloading dataset") 18 | data = re.get(url) 19 | with open(DOWNLOADED_ZIP_FILE_NAME, "wb") as f: 20 | f.write(data.content) 21 | return None 22 | 23 | def extract_data(): 24 | print("Extracting dataset") 25 | os.system(f"tar -xvzf {DOWNLOADED_ZIP_FILE_NAME} > /dev/null 2>&1") 26 | files = os.listdir(EXTRACTED_FOLDER_NAME) 27 | for file in files: 28 | if file != RAW_DATA_FILE_NAME: 29 | os.remove(f"{EXTRACTED_FOLDER_NAME}/{file}" ) 30 | os.rename(f"{EXTRACTED_FOLDER_NAME}/{RAW_DATA_FILE_NAME}", f"{EXTRACTED_FOLDER_NAME}/{FILE_NAME}") 31 | return None 32 | 33 | def clean_data(df): 34 | df = df[df['user'] == 8] 35 | df = df.drop(['user'], axis=1) 36 | df = df[['timestamp', 'x', 'y', 'z', 'activity']] 37 | rename_columns = {'x': 'Acc_X', 'y': 'Acc_Y', 'z': 'Acc_Z', 'activity': 'Target', 'timestamp': 'Time'} 38 | df.rename(columns=rename_columns, inplace=True) 39 | return df 40 | 41 | def load_data(): 42 | columns = ["user", "activity", "timestamp", "x", "y", "z"] 43 | file = open(f"{EXTRACTED_FOLDER_NAME}/{FILE_NAME}", "r") 44 | data = file.read() 45 | file.close() 46 | data = data.replace(";\n", "\n").replace(";", "\n").replace("\n\n", "\n").replace(",\n", "\n") 47 | file = open(f"{EXTRACTED_FOLDER_NAME}/{FILE_NAME}", "w") 48 | file.write(data) 49 | file.close() 50 | data = pd.read_csv(f"{EXTRACTED_FOLDER_NAME}/{FILE_NAME}", header=None, names=columns) 51 | data = clean_data(data) 52 | return data 53 | 54 | 55 | def store_datafiles(df): 56 | unique_targets = df['Target'].unique() 57 | if not os.path.exists("classes"): 58 | os.mkdir("classes") 59 | 60 | for idx, target in enumerate(unique_targets): 61 | if not os.path.exists(f"classes/class_{idx}_{target.lower()}"): 62 | os.mkdir(f"classes/class_{idx}_{target.lower()}") 63 | current_target_df = df[df['Target'] == target] 64 | num_splits = NUM_SPLITS 65 | chunk_size = len(current_target_df) // num_splits 66 | current_target_dfs = [current_target_df[i*chunk_size:(i+1)*chunk_size] for i in range(num_splits)] 67 | for df_idx, current_target_df in enumerate(current_target_dfs): 68 | current_target_df = current_target_df.drop(['Target'], axis=1) 69 | current_target_df.to_csv(f"classes/class_{idx}_{target.lower()}/{target.lower()}_{df_idx}.csv", index=False) 70 | print("Created classes/class_{}_{}".format(idx, target.lower())) 71 | 72 | def cleanup(): 73 | os.system(f"rm -rf {EXTRACTED_FOLDER_NAME} > /dev/null 2>&1") 74 | os.system(f"rm {DOWNLOADED_ZIP_FILE_NAME} > /dev/null 2>&1") 75 | 76 | def zip_files(): 77 | print(f"Zipping the classes into {CREATED_ZIP_FILE_NAME}") 78 | os.system(f"zip -r {CREATED_ZIP_FILE_NAME} classes > /dev/null 2>&1") 79 | os.system("rm -rf classes > /dev/null 2>&1") 80 | 81 | if __name__ == '__main__': 82 | 83 | download_data() 84 | extract_data() 85 | 86 | df = load_data() 87 | 88 | store_datafiles(df) 89 | zip_files() 90 | 91 | cleanup() 92 | -------------------------------------------------------------------------------- /tinyml-modelmaker/examples/data_processing_and_feature_extraction/config_timeseries_classification_motor_fault_dsk.yaml: -------------------------------------------------------------------------------- 1 | common: 2 | target_module: 'timeseries' 3 | task_type: 'generic_timeseries_classification' 4 | target_device: 'F28P55' 5 | run_name: '{date-time}/{model_name}' 6 | 7 | dataset: 8 | # enable/disable dataset loading 9 | enable: True 10 | dataset_name: motor_fault_classification_dsk 11 | input_data_path: 'http://software-dl.ti.com/C2000/esd/mcu_ai/01_00_00/datasets/motor_fault_classification_dsk.zip' 12 | 13 | data_processing_feature_extraction: 14 | 15 | ### Available data processing transforms: ['DownSample', 'SimpleWindow'] 16 | # data_proc_transforms: [] 17 | 18 | # Downsample 19 | # sampling_rate: 313000 20 | # new_sr: 3130 21 | 22 | # SimpleWindow 23 | # frame_size: 512 24 | # stride_size: 0.01 25 | 26 | # Available feature extraction presets 27 | # feature_extraction_name: MotorFault_256Input_FFTBIN_16Feature_8Frame_3InputChannel_removeDC_1D 28 | feature_extraction_name: MotorFault_256Input_FFTBIN_16Feature_8Frame_3InputChannel_removeDC_2D1 29 | # feature_extraction_name: MotorFault_256Input_FFT_128Feature_1Frame_3InputChannel_removeDC_2D1 30 | # feature_extraction_name: MotorFault_128Input_RAW_128Feature_1Frame_3InputChannel_removeDC_2D1 31 | 32 | # Custom feature extraction 33 | # feature_extraction_name: Custom_MotorFault 34 | # feature_size_per_frame: 64 35 | # num_frame_concat: 2 36 | # normalize_bin: 1 37 | # stacking: 2D1 38 | # feat_ext_transform: ['FFT_FE', 'FFT_POS_HALF', 'DC_REMOVE', 'ABS', 'BINNING', 'LOG_DB', 'CONCAT'] 39 | # offset: 0 40 | # scale: 1 41 | # frame_skip: 1 42 | # log_mul: 20 43 | # log_base: 10 44 | # log_threshold: 1e-100 45 | # store_feat_ext_data: False 46 | # variables: 3 47 | 48 | training: 49 | # enable/disable training 50 | enable: True 51 | model_name: 'TimeSeries_Generic_6k_t' 52 | model_config: '' 53 | batch_size: 256 54 | training_epochs: 5 55 | num_gpus: 0 56 | learning_rate: 0.04 57 | 58 | testing: 59 | enable: False 60 | 61 | compilation: 62 | # enable/disable compilation 63 | enable: False #True 64 | # No preset is required for devices other than F28P55 65 | -------------------------------------------------------------------------------- /tinyml-modelmaker/examples/electrical_fault/assets/simulink.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TexasInstruments/tinyml-tensorlab/3a2d9e8eefdb3ee560d42aa8c01e31eeaf79f166/tinyml-modelmaker/examples/electrical_fault/assets/simulink.png -------------------------------------------------------------------------------- /tinyml-modelmaker/examples/electrical_fault/config_classification_electrical_fault.yaml: -------------------------------------------------------------------------------- 1 | 2 | common: 3 | target_module: 'timeseries' 4 | task_type: 'generic_timeseries_classification' 5 | target_device: 'F28P55' 6 | run_name: '{date-time}/{model_name}' 7 | 8 | dataset: 9 | # enable/disable dataset loading 10 | enable: True #False 11 | dataset_name: electrical_fault 12 | input_data_path: 'examples/electrical_fault/electrical_fault_dataset.zip' 13 | 14 | data_processing_feature_extraction: 15 | data_proc_transforms: [SimpleWindow] 16 | # SimpleWindow 17 | frame_size: 192 18 | stride_size: 0.01 19 | variables: 6 20 | 21 | feature_extraction_name: Custom_Default 22 | feat_ext_transform: [] 23 | # FFT with Binning 24 | # feat_ext_transform: ['FFT_FE', 'FFT_POS_HALF', 'DC_REMOVE', 'ABS', 'BINNING', 'LOG_DB', 'CONCAT'] 25 | # frame_size: 192 26 | # feature_size_per_frame: 48 27 | # num_frame_concat: 4 28 | 29 | # FFT without Binning 30 | # feat_ext_transform: ['FFT_FE', 'FFT_POS_HALF', 'DC_REMOVE', 'ABS', 'LOG_DB', 'CONCAT'] 31 | # frame_size: 192 32 | # feature_size_per_frame: 96 33 | # num_frame_concat: 4 34 | 35 | training: 36 | # enable/disable training 37 | enable: True #False 38 | model_name: 'Res_Slice_TimeSeries_Generic_3k_t' 39 | num_gpus: 0 40 | 41 | testing: 42 | enable: True 43 | skip_train: False # True 44 | 45 | compilation: 46 | # enable/disable compilation 47 | enable: True #False -------------------------------------------------------------------------------- /tinyml-modelmaker/examples/electrical_fault/electrical_fault.py: -------------------------------------------------------------------------------- 1 | import os 2 | import requests as re 3 | 4 | import pandas as pd 5 | 6 | # Project Definition 7 | DATASET_NAME = "electrical_fault" 8 | 9 | # Dataset definition 10 | DATASET_URL = "http://software-dl.ti.com/C2000/esd/mcu_ai/01_00_00/datasets/electrical_fault.zip" 11 | DATASET_FILE_NAME = "detect_dataset.csv" 12 | independent_variables = ["Ia", "Ib", "Ic", "Va", "Vb", "Vc"] 13 | dependent_variables = ["Output (S)"] 14 | 15 | # Dataset Processing 16 | NUM_SPLITS = 4 17 | rename_target = {dependent_variables[0]: "Target"} 18 | replace_target_values = {0: "unstable", 1: "stable"} 19 | 20 | def download_data(): 21 | print("Downloading dataset") 22 | data = re.get(DATASET_URL) 23 | with open(f"{DATASET_NAME}.zip", "wb") as f: 24 | f.write(data.content) 25 | return None 26 | 27 | def extract_data(): 28 | print("Extracting dataset") 29 | os.system(f"unzip {DATASET_NAME}.zip -d {DATASET_NAME} > /dev/null 2>&1") 30 | return None 31 | 32 | def load_data(): 33 | data = pd.read_csv(f"{DATASET_NAME}/{DATASET_FILE_NAME}", index_col=False) 34 | columns = independent_variables + dependent_variables 35 | data = data[columns] 36 | data.rename(columns=rename_target, inplace=True) 37 | data['Target'] = data['Target'].replace(replace_target_values) 38 | return data 39 | 40 | 41 | def store_datafiles(df): 42 | unique_targets = df['Target'].unique() 43 | if not os.path.exists("classes"): 44 | os.mkdir("classes") 45 | 46 | for idx, target in enumerate(unique_targets): 47 | if not os.path.exists(f"classes/class_{idx}_{target.lower()}"): 48 | os.mkdir(f"classes/class_{idx}_{target.lower()}") 49 | current_target_df = df[df['Target'] == target] 50 | num_splits = NUM_SPLITS 51 | chunk_size = len(current_target_df) // num_splits 52 | current_target_dfs = [current_target_df[i*chunk_size:(i+1)*chunk_size] for i in range(num_splits)] 53 | for df_idx, current_target_df in enumerate(current_target_dfs): 54 | current_target_df = current_target_df.drop(['Target'], axis=1) 55 | current_target_df.to_csv(f"classes/class_{idx}_{target.lower()}/{target.lower()}_{df_idx}.csv", index=False) 56 | print("Created classes/class_{}_{}".format(idx, target.lower())) 57 | 58 | def cleanup(): 59 | os.system(f"rm -rf {DATASET_NAME} > /dev/null 2>&1") 60 | os.system(f"rm {DATASET_NAME}.zip > /dev/null 2>&1") 61 | 62 | def zip_files(): 63 | print(f"Zipping the classes into {DATASET_NAME}_dataset.zip") 64 | os.system(f"zip -r {DATASET_NAME}_dataset.zip classes > /dev/null 2>&1") 65 | os.system("rm -rf classes > /dev/null 2>&1") 66 | 67 | if __name__ == '__main__': 68 | 69 | download_data() 70 | extract_data() 71 | 72 | df = load_data() 73 | 74 | store_datafiles(df) 75 | zip_files() 76 | 77 | cleanup() 78 | -------------------------------------------------------------------------------- /tinyml-modelmaker/examples/fan_blade_fault_classification/assets/Blade Damage.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TexasInstruments/tinyml-tensorlab/3a2d9e8eefdb3ee560d42aa8c01e31eeaf79f166/tinyml-modelmaker/examples/fan_blade_fault_classification/assets/Blade Damage.jpg -------------------------------------------------------------------------------- /tinyml-modelmaker/examples/fan_blade_fault_classification/assets/Blade Imbalance.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TexasInstruments/tinyml-tensorlab/3a2d9e8eefdb3ee560d42aa8c01e31eeaf79f166/tinyml-modelmaker/examples/fan_blade_fault_classification/assets/Blade Imbalance.jpg -------------------------------------------------------------------------------- /tinyml-modelmaker/examples/fan_blade_fault_classification/assets/Blade Obstruction.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TexasInstruments/tinyml-tensorlab/3a2d9e8eefdb3ee560d42aa8c01e31eeaf79f166/tinyml-modelmaker/examples/fan_blade_fault_classification/assets/Blade Obstruction.jpg -------------------------------------------------------------------------------- /tinyml-modelmaker/examples/fan_blade_fault_classification/assets/Demo Setup.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TexasInstruments/tinyml-tensorlab/3a2d9e8eefdb3ee560d42aa8c01e31eeaf79f166/tinyml-modelmaker/examples/fan_blade_fault_classification/assets/Demo Setup.jpg -------------------------------------------------------------------------------- /tinyml-modelmaker/examples/fan_blade_fault_classification/assets/Histogram_Class_Score_differences_test.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TexasInstruments/tinyml-tensorlab/3a2d9e8eefdb3ee560d42aa8c01e31eeaf79f166/tinyml-modelmaker/examples/fan_blade_fault_classification/assets/Histogram_Class_Score_differences_test.png -------------------------------------------------------------------------------- /tinyml-modelmaker/examples/fan_blade_fault_classification/assets/Normal.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TexasInstruments/tinyml-tensorlab/3a2d9e8eefdb3ee560d42aa8c01e31eeaf79f166/tinyml-modelmaker/examples/fan_blade_fault_classification/assets/Normal.jpg -------------------------------------------------------------------------------- /tinyml-modelmaker/examples/fan_blade_fault_classification/assets/One_vs_Rest_MultiClass_ROC_test.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TexasInstruments/tinyml-tensorlab/3a2d9e8eefdb3ee560d42aa8c01e31eeaf79f166/tinyml-modelmaker/examples/fan_blade_fault_classification/assets/One_vs_Rest_MultiClass_ROC_test.png -------------------------------------------------------------------------------- /tinyml-modelmaker/examples/fan_blade_fault_classification/assets/adxl355_pmdz_pinout.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TexasInstruments/tinyml-tensorlab/3a2d9e8eefdb3ee560d42aa8c01e31eeaf79f166/tinyml-modelmaker/examples/fan_blade_fault_classification/assets/adxl355_pmdz_pinout.png -------------------------------------------------------------------------------- /tinyml-modelmaker/examples/fan_blade_fault_classification/assets/eAI_data_acq_dap_f28p55x.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TexasInstruments/tinyml-tensorlab/3a2d9e8eefdb3ee560d42aa8c01e31eeaf79f166/tinyml-modelmaker/examples/fan_blade_fault_classification/assets/eAI_data_acq_dap_f28p55x.zip -------------------------------------------------------------------------------- /tinyml-modelmaker/examples/fan_blade_fault_classification/assets/eAI_mfd_eval_f28p55x.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TexasInstruments/tinyml-tensorlab/3a2d9e8eefdb3ee560d42aa8c01e31eeaf79f166/tinyml-modelmaker/examples/fan_blade_fault_classification/assets/eAI_mfd_eval_f28p55x.zip -------------------------------------------------------------------------------- /tinyml-modelmaker/examples/fan_blade_fault_classification/assets/f28p55_launchpad_pinout.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TexasInstruments/tinyml-tensorlab/3a2d9e8eefdb3ee560d42aa8c01e31eeaf79f166/tinyml-modelmaker/examples/fan_blade_fault_classification/assets/f28p55_launchpad_pinout.jpg -------------------------------------------------------------------------------- /tinyml-modelmaker/examples/fan_blade_fault_classification/assets/fan_blade_demo_model_composer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TexasInstruments/tinyml-tensorlab/3a2d9e8eefdb3ee560d42aa8c01e31eeaf79f166/tinyml-modelmaker/examples/fan_blade_fault_classification/assets/fan_blade_demo_model_composer.png -------------------------------------------------------------------------------- /tinyml-modelmaker/examples/fan_blade_fault_classification/assets/live_capture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TexasInstruments/tinyml-tensorlab/3a2d9e8eefdb3ee560d42aa8c01e31eeaf79f166/tinyml-modelmaker/examples/fan_blade_fault_classification/assets/live_capture.png -------------------------------------------------------------------------------- /tinyml-modelmaker/examples/fan_blade_fault_classification/assets/pca_on_feature_extracted_train_data.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TexasInstruments/tinyml-tensorlab/3a2d9e8eefdb3ee560d42aa8c01e31eeaf79f166/tinyml-modelmaker/examples/fan_blade_fault_classification/assets/pca_on_feature_extracted_train_data.png -------------------------------------------------------------------------------- /tinyml-modelmaker/examples/fan_blade_fault_classification/assets/pca_on_feature_extracted_validation_data.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TexasInstruments/tinyml-tensorlab/3a2d9e8eefdb3ee560d42aa8c01e31eeaf79f166/tinyml-modelmaker/examples/fan_blade_fault_classification/assets/pca_on_feature_extracted_validation_data.png -------------------------------------------------------------------------------- /tinyml-modelmaker/examples/fan_blade_fault_classification/config_timeseries_classification_fan_blade_dsi.yaml: -------------------------------------------------------------------------------- 1 | 2 | common: 3 | target_module: 'timeseries' 4 | task_type: 'generic_timeseries_classification' 5 | target_device: 'F28P55' 6 | run_name: '{date-time}/{model_name}' 7 | dataset: 8 | # enable/disable dataset loading 9 | enable: True #False 10 | dataset_name: fan_blade_fault_dsi 11 | input_data_path: /home/a0484689/Downloads/fan_blade_fault_dsi.zip 12 | 13 | data_processing: # One or more can be cascaded in the list 14 | transforms: [] 15 | feature_extraction: 16 | # feature_extraction_name: MotorFault_256Input_FFTBIN_16Feature_8Frame_3InputChannel_removeDC_1D 17 | # feature_extraction_name: MotorFault_256Input_FFTBIN_16Feature_8Frame_3InputChannel_removeDC_2D1 18 | # feature_extraction_name: MotorFault_256Input_FFT_128Feature_1Frame_3InputChannel_removeDC_2D1 19 | # feature_extraction_name: MotorFault_128Input_RAW_128Feature_1Frame_3InputChannel_removeDC_2D1 20 | feature_extraction_name: Custom_MotorFault 21 | # transform: [] 22 | frame_size: 64 23 | feature_size_per_frame: 8 24 | num_frame_concat: 8 25 | normalize_bin: 1 26 | stacking: 2D1 27 | transform: ['FFT_FE', 'FFT_POS_HALF', 'DC_REMOVE', 'ABS', 'BINNING', 'LOG_DB', 'CONCAT'] 28 | offset: 0 29 | scale: 1 30 | frame_skip: 1 31 | log_mul: 20 32 | log_base: 10 33 | log_threshold: 1e-100 34 | store_feat_ext_data: False 35 | nn_for_feature_extraction: False 36 | 37 | training: 38 | # enable/disable training 39 | enable: True #False 40 | # F28x generic timeseries model names: TimeSeries_Generic_1k_t, TimeSeries_Generic_4k_t, TimeSeries_Generic_6k_t, TimeSeries_Generic_13k_t 41 | # GUI only model names: MotorFault_model_1_t, MotorFault_model_2_t, MotorFault_model_3_t 42 | model_name: 'TimeSeries_Generic_6k_t' 43 | # model_spec: '../tinyml-mlbackend/proprietary_models/cnn_mf_1l.py' 44 | model_config: '' 45 | batch_size: 256 46 | training_epochs: 20 47 | num_gpus: 0 # 1 48 | # learning_rate: 0.001 49 | 50 | testing: 51 | enable: True 52 | 53 | compilation: 54 | # enable/disable compilation 55 | enable: True #False 56 | # No preset is required for devices other than F28P55 57 | # compile_preset_name: forced_soft_npu_preset 58 | -------------------------------------------------------------------------------- /tinyml-modelmaker/examples/goodness_of_fit_test/GoF_plots/arc_fault_dsi_GoF_frame_size_1024.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TexasInstruments/tinyml-tensorlab/3a2d9e8eefdb3ee560d42aa8c01e31eeaf79f166/tinyml-modelmaker/examples/goodness_of_fit_test/GoF_plots/arc_fault_dsi_GoF_frame_size_1024.png -------------------------------------------------------------------------------- /tinyml-modelmaker/examples/goodness_of_fit_test/GoF_plots/arc_fault_dsi_GoF_frame_size_2048.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TexasInstruments/tinyml-tensorlab/3a2d9e8eefdb3ee560d42aa8c01e31eeaf79f166/tinyml-modelmaker/examples/goodness_of_fit_test/GoF_plots/arc_fault_dsi_GoF_frame_size_2048.png -------------------------------------------------------------------------------- /tinyml-modelmaker/examples/goodness_of_fit_test/GoF_plots/arc_fault_dsi_GoF_frame_size_256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TexasInstruments/tinyml-tensorlab/3a2d9e8eefdb3ee560d42aa8c01e31eeaf79f166/tinyml-modelmaker/examples/goodness_of_fit_test/GoF_plots/arc_fault_dsi_GoF_frame_size_256.png -------------------------------------------------------------------------------- /tinyml-modelmaker/examples/goodness_of_fit_test/GoF_plots/arc_fault_dsi_GoF_frame_size_4096.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TexasInstruments/tinyml-tensorlab/3a2d9e8eefdb3ee560d42aa8c01e31eeaf79f166/tinyml-modelmaker/examples/goodness_of_fit_test/GoF_plots/arc_fault_dsi_GoF_frame_size_4096.png -------------------------------------------------------------------------------- /tinyml-modelmaker/examples/goodness_of_fit_test/GoF_plots/arc_fault_dsi_GoF_frame_size_512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TexasInstruments/tinyml-tensorlab/3a2d9e8eefdb3ee560d42aa8c01e31eeaf79f166/tinyml-modelmaker/examples/goodness_of_fit_test/GoF_plots/arc_fault_dsi_GoF_frame_size_512.png -------------------------------------------------------------------------------- /tinyml-modelmaker/examples/goodness_of_fit_test/GoF_plots/motor_dsk3inp_GoF_frame_size_256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TexasInstruments/tinyml-tensorlab/3a2d9e8eefdb3ee560d42aa8c01e31eeaf79f166/tinyml-modelmaker/examples/goodness_of_fit_test/GoF_plots/motor_dsk3inp_GoF_frame_size_256.png -------------------------------------------------------------------------------- /tinyml-modelmaker/examples/goodness_of_fit_test/GoF_plots/motor_dsk3inp_GoF_frame_size_256_40Hz.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TexasInstruments/tinyml-tensorlab/3a2d9e8eefdb3ee560d42aa8c01e31eeaf79f166/tinyml-modelmaker/examples/goodness_of_fit_test/GoF_plots/motor_dsk3inp_GoF_frame_size_256_40Hz.png -------------------------------------------------------------------------------- /tinyml-modelmaker/examples/goodness_of_fit_test/GoF_plots/motor_dsk_GoF_frame_size_256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TexasInstruments/tinyml-tensorlab/3a2d9e8eefdb3ee560d42aa8c01e31eeaf79f166/tinyml-modelmaker/examples/goodness_of_fit_test/GoF_plots/motor_dsk_GoF_frame_size_256.png -------------------------------------------------------------------------------- /tinyml-modelmaker/examples/goodness_of_fit_test/GoF_plots/motor_dsk_GoF_frame_size_256_40Hz.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TexasInstruments/tinyml-tensorlab/3a2d9e8eefdb3ee560d42aa8c01e31eeaf79f166/tinyml-modelmaker/examples/goodness_of_fit_test/GoF_plots/motor_dsk_GoF_frame_size_256_40Hz.png -------------------------------------------------------------------------------- /tinyml-modelmaker/examples/goodness_of_fit_test/GoF_plots/motor_dsk_GoF_frame_size_256_40Hz_m1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TexasInstruments/tinyml-tensorlab/3a2d9e8eefdb3ee560d42aa8c01e31eeaf79f166/tinyml-modelmaker/examples/goodness_of_fit_test/GoF_plots/motor_dsk_GoF_frame_size_256_40Hz_m1.png -------------------------------------------------------------------------------- /tinyml-modelmaker/examples/goodness_of_fit_test/config_timeseries_classification_motor_fault_dsk3.yaml: -------------------------------------------------------------------------------- 1 | common: 2 | target_module: 'timeseries' 3 | task_type: 'generic_timeseries_classification' 4 | target_device: 'F28P55' 5 | run_name: '{date-time}/{model_name}' 6 | 7 | dataset: 8 | # enable/disable dataset loading 9 | enable: True 10 | dataset_name: motor_fault_classification_dsk3 11 | input_data_path: 'http://software-dl.ti.com/C2000/esd/mcu_ai/01_00_00/datasets/motor_fault_classification_dsk_3inp.zip' 12 | 13 | data_processing_feature_extraction: 14 | feature_extraction_name: 'MotorFault_256Input_FFTBIN_16Feature_8Frame_3InputChannel_removeDC_2D1' 15 | gof_test: True 16 | frame_size: 256 17 | 18 | training: 19 | # enable/disable training 20 | enable: True 21 | model_name: 'TimeSeries_Generic_6k_t' 22 | model_config: '' 23 | batch_size: 256 24 | training_epochs: 5 25 | num_gpus: 0 26 | learning_rate: 0.04 27 | 28 | testing: 29 | enable: False 30 | 31 | compilation: 32 | # enable/disable compilation 33 | enable: False #True 34 | # No preset is required for devices other than F28P55 35 | -------------------------------------------------------------------------------- /tinyml-modelmaker/examples/grid_stability/config_classification_grid_stability.yaml: -------------------------------------------------------------------------------- 1 | 2 | common: 3 | target_module: 'timeseries' 4 | task_type: 'generic_timeseries_classification' 5 | target_device: 'F28P55' 6 | run_name: '{date-time}/{model_name}' 7 | 8 | dataset: 9 | # enable/disable dataset loading 10 | enable: True #False 11 | dataset_name: grid_stability 12 | input_data_path: 'examples/grid_stability/grid_stability_dataset.zip' 13 | 14 | data_processing_feature_extraction: 15 | data_proc_transforms: [SimpleWindow] 16 | # SimpleWindow 17 | frame_size: 192 18 | stride_size: 0.01 19 | variables: 6 20 | 21 | feature_extraction_name: Custom_Default 22 | # FFT with Binning 23 | feat_ext_transform: ['FFT_FE', 'FFT_POS_HALF', 'DC_REMOVE', 'ABS', 'BINNING', 'LOG_DB', 'CONCAT'] 24 | frame_size: 192 25 | feature_size_per_frame: 48 26 | num_frame_concat: 4 27 | 28 | training: 29 | # enable/disable training 30 | enable: True #False 31 | model_name: 'Res_Slice_TimeSeries_Generic_3k_t' 32 | num_gpus: 0 33 | 34 | testing: 35 | enable: True 36 | skip_train: False # True 37 | 38 | compilation: 39 | # enable/disable compilation 40 | enable: True #False -------------------------------------------------------------------------------- /tinyml-modelmaker/examples/grid_stability/grid_stability.py: -------------------------------------------------------------------------------- 1 | import os 2 | import requests as re 3 | 4 | import pandas as pd 5 | 6 | # Project Definition 7 | DATASET_NAME = "grid_stability" 8 | 9 | # Dataset definition 10 | DATASET_URL = "https://archive.ics.uci.edu/static/public/471/electrical+grid+stability+simulated+data.zip" 11 | DATASET_FILE_NAME = "Data_for_UCI_named.csv" 12 | independent_variables = ["tau1", "tau2", "tau3", "tau4", "p1", "p2", "p3", "p4", "g1", "g2", "g3", "g4"] 13 | dependent_variables = ["stabf"] 14 | 15 | # Dataset Processing 16 | NUM_SPLITS = 4 17 | rename_target = {dependent_variables[0]: "Target"} 18 | replace_target_values = {} 19 | 20 | def download_data(): 21 | print("Downloading dataset") 22 | data = re.get(DATASET_URL) 23 | with open(f"{DATASET_NAME}.zip", "wb") as f: 24 | f.write(data.content) 25 | return None 26 | 27 | def extract_data(): 28 | print("Extracting dataset") 29 | os.system(f"unzip {DATASET_NAME}.zip -d {DATASET_NAME} > /dev/null 2>&1") 30 | return None 31 | 32 | def load_data(): 33 | data = pd.read_csv(f"{DATASET_NAME}/{DATASET_FILE_NAME}", index_col=False) 34 | columns = independent_variables + dependent_variables 35 | data = data[columns] 36 | data.rename(columns=rename_target, inplace=True) 37 | data['Target'] = data['Target'].replace(replace_target_values) 38 | return data 39 | 40 | 41 | def store_datafiles(df): 42 | unique_targets = df['Target'].unique() 43 | if not os.path.exists("classes"): 44 | os.mkdir("classes") 45 | 46 | for idx, target in enumerate(unique_targets): 47 | if not os.path.exists(f"classes/class_{idx}_{target.lower()}"): 48 | os.mkdir(f"classes/class_{idx}_{target.lower()}") 49 | current_target_df = df[df['Target'] == target] 50 | num_splits = NUM_SPLITS 51 | chunk_size = len(current_target_df) // num_splits 52 | current_target_dfs = [current_target_df[i*chunk_size:(i+1)*chunk_size] for i in range(num_splits)] 53 | for df_idx, current_target_df in enumerate(current_target_dfs): 54 | current_target_df = current_target_df.drop(['Target'], axis=1) 55 | current_target_df.to_csv(f"classes/class_{idx}_{target.lower()}/{target.lower()}_{df_idx}.csv", index=False) 56 | print("Created classes/class_{}_{}".format(idx, target.lower())) 57 | 58 | def cleanup(): 59 | os.system(f"rm -rf {DATASET_NAME} > /dev/null 2>&1") 60 | os.system(f"rm {DATASET_NAME}.zip > /dev/null 2>&1") 61 | 62 | def zip_files(): 63 | print(f"Zipping the classes into {DATASET_NAME}_dataset.zip") 64 | os.system(f"zip -r {DATASET_NAME}_dataset.zip classes > /dev/null 2>&1") 65 | os.system("rm -rf classes > /dev/null 2>&1") 66 | 67 | if __name__ == '__main__': 68 | 69 | download_data() 70 | extract_data() 71 | 72 | df = load_data() 73 | 74 | store_datafiles(df) 75 | zip_files() 76 | 77 | cleanup() 78 | -------------------------------------------------------------------------------- /tinyml-modelmaker/examples/how_good_is_your_feature_extraction/arc_fault_dsi/pca_on_feature_extracted_train_data.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TexasInstruments/tinyml-tensorlab/3a2d9e8eefdb3ee560d42aa8c01e31eeaf79f166/tinyml-modelmaker/examples/how_good_is_your_feature_extraction/arc_fault_dsi/pca_on_feature_extracted_train_data.png -------------------------------------------------------------------------------- /tinyml-modelmaker/examples/how_good_is_your_feature_extraction/arc_fault_dsi/pca_on_feature_extracted_validation_data.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TexasInstruments/tinyml-tensorlab/3a2d9e8eefdb3ee560d42aa8c01e31eeaf79f166/tinyml-modelmaker/examples/how_good_is_your_feature_extraction/arc_fault_dsi/pca_on_feature_extracted_validation_data.png -------------------------------------------------------------------------------- /tinyml-modelmaker/examples/how_good_is_your_feature_extraction/arc_fault_dsk/pca_on_feature_extracted_train_data.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TexasInstruments/tinyml-tensorlab/3a2d9e8eefdb3ee560d42aa8c01e31eeaf79f166/tinyml-modelmaker/examples/how_good_is_your_feature_extraction/arc_fault_dsk/pca_on_feature_extracted_train_data.png -------------------------------------------------------------------------------- /tinyml-modelmaker/examples/how_good_is_your_feature_extraction/arc_fault_dsk/pca_on_feature_extracted_validation_data.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TexasInstruments/tinyml-tensorlab/3a2d9e8eefdb3ee560d42aa8c01e31eeaf79f166/tinyml-modelmaker/examples/how_good_is_your_feature_extraction/arc_fault_dsk/pca_on_feature_extracted_validation_data.png -------------------------------------------------------------------------------- /tinyml-modelmaker/examples/how_good_is_your_feature_extraction/motor_bearing_fault_dsk/pca_on_feature_extracted_train_data_MotorFault_128Input_RAW_128Feature_1Frame_3InputChannel_removeDC_2D1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TexasInstruments/tinyml-tensorlab/3a2d9e8eefdb3ee560d42aa8c01e31eeaf79f166/tinyml-modelmaker/examples/how_good_is_your_feature_extraction/motor_bearing_fault_dsk/pca_on_feature_extracted_train_data_MotorFault_128Input_RAW_128Feature_1Frame_3InputChannel_removeDC_2D1.png -------------------------------------------------------------------------------- /tinyml-modelmaker/examples/how_good_is_your_feature_extraction/motor_bearing_fault_dsk/pca_on_feature_extracted_train_data_MotorFault_256Input_FFTBIN_16Feature_8Frame_3InputChannel_removeDC_1D.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TexasInstruments/tinyml-tensorlab/3a2d9e8eefdb3ee560d42aa8c01e31eeaf79f166/tinyml-modelmaker/examples/how_good_is_your_feature_extraction/motor_bearing_fault_dsk/pca_on_feature_extracted_train_data_MotorFault_256Input_FFTBIN_16Feature_8Frame_3InputChannel_removeDC_1D.png -------------------------------------------------------------------------------- /tinyml-modelmaker/examples/how_good_is_your_feature_extraction/motor_bearing_fault_dsk/pca_on_feature_extracted_train_data_MotorFault_256Input_FFTBIN_16Feature_8Frame_3InputChannel_removeDC_2D1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TexasInstruments/tinyml-tensorlab/3a2d9e8eefdb3ee560d42aa8c01e31eeaf79f166/tinyml-modelmaker/examples/how_good_is_your_feature_extraction/motor_bearing_fault_dsk/pca_on_feature_extracted_train_data_MotorFault_256Input_FFTBIN_16Feature_8Frame_3InputChannel_removeDC_2D1.png -------------------------------------------------------------------------------- /tinyml-modelmaker/examples/how_good_is_your_feature_extraction/motor_bearing_fault_dsk/pca_on_feature_extracted_train_data_MotorFault_256Input_FFT_128Feature_1Frame_3InputChannel_removeDC_2D1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TexasInstruments/tinyml-tensorlab/3a2d9e8eefdb3ee560d42aa8c01e31eeaf79f166/tinyml-modelmaker/examples/how_good_is_your_feature_extraction/motor_bearing_fault_dsk/pca_on_feature_extracted_train_data_MotorFault_256Input_FFT_128Feature_1Frame_3InputChannel_removeDC_2D1.png -------------------------------------------------------------------------------- /tinyml-modelmaker/examples/how_good_is_your_feature_extraction/motor_bearing_fault_dsk/pca_on_feature_extracted_validation_data_MotorFault_128Input_RAW_128Feature_1Frame_3InputChannel_removeDC_2D1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TexasInstruments/tinyml-tensorlab/3a2d9e8eefdb3ee560d42aa8c01e31eeaf79f166/tinyml-modelmaker/examples/how_good_is_your_feature_extraction/motor_bearing_fault_dsk/pca_on_feature_extracted_validation_data_MotorFault_128Input_RAW_128Feature_1Frame_3InputChannel_removeDC_2D1.png -------------------------------------------------------------------------------- /tinyml-modelmaker/examples/how_good_is_your_feature_extraction/motor_bearing_fault_dsk/pca_on_feature_extracted_validation_data_MotorFault_256Input_FFTBIN_16Feature_8Frame_3InputChannel_removeDC_1D.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TexasInstruments/tinyml-tensorlab/3a2d9e8eefdb3ee560d42aa8c01e31eeaf79f166/tinyml-modelmaker/examples/how_good_is_your_feature_extraction/motor_bearing_fault_dsk/pca_on_feature_extracted_validation_data_MotorFault_256Input_FFTBIN_16Feature_8Frame_3InputChannel_removeDC_1D.png -------------------------------------------------------------------------------- /tinyml-modelmaker/examples/how_good_is_your_feature_extraction/motor_bearing_fault_dsk/pca_on_feature_extracted_validation_data_MotorFault_256Input_FFTBIN_16Feature_8Frame_3InputChannel_removeDC_2D1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TexasInstruments/tinyml-tensorlab/3a2d9e8eefdb3ee560d42aa8c01e31eeaf79f166/tinyml-modelmaker/examples/how_good_is_your_feature_extraction/motor_bearing_fault_dsk/pca_on_feature_extracted_validation_data_MotorFault_256Input_FFTBIN_16Feature_8Frame_3InputChannel_removeDC_2D1.png -------------------------------------------------------------------------------- /tinyml-modelmaker/examples/how_good_is_your_feature_extraction/motor_bearing_fault_dsk/pca_on_feature_extracted_validation_data_MotorFault_256Input_FFT_128Feature_1Frame_3InputChannel_removeDC_2D1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TexasInstruments/tinyml-tensorlab/3a2d9e8eefdb3ee560d42aa8c01e31eeaf79f166/tinyml-modelmaker/examples/how_good_is_your_feature_extraction/motor_bearing_fault_dsk/pca_on_feature_extracted_validation_data_MotorFault_256Input_FFT_128Feature_1Frame_3InputChannel_removeDC_2D1.png -------------------------------------------------------------------------------- /tinyml-modelmaker/examples/nilm_appliance_usage_classification/config_timeseries_classification_nilm.yaml: -------------------------------------------------------------------------------- 1 | 2 | common: 3 | target_module: 'timeseries' 4 | task_type: 'generic_timeseries_classification' 5 | target_device: 'F28P55' 6 | run_name: '{date-time}/{model_name}' 7 | 8 | dataset: 9 | enable: True 10 | dataset_name: esda_nilm_2021_5_variable_4_class_dataset 11 | input_data_path: 'http://software-dl.ti.com/C2000/esd/mcu_ai/01_00_00/datasets/esda_nilm_2021_5_variable_4_class_dataset.zip' 12 | 13 | data_processing_feature_extraction: 14 | feat_ext_transform: ['FFT_FE', 'FFT_POS_HALF', 'WINDOWING', 'BINNING', 'NORMALIZE', 'ABS','LOG_DB', 'CONCAT',] 15 | frame_size: 32 16 | feature_size_per_frame: 8 17 | num_frame_concat: 8 18 | variables: 5 19 | 20 | training: 21 | enable: True 22 | model_name: 'TimeSeries_Generic_6k_t' 23 | model_config: '' 24 | batch_size: 256 25 | training_epochs: 20 26 | num_gpus: 0 27 | learning_rate: 0.04 28 | 29 | testing: 30 | enable: True 31 | 32 | compilation: 33 | enable: True 34 | -------------------------------------------------------------------------------- /tinyml-modelmaker/examples/post_training_analysis/arc_fault_dsi/Histogram_Class_Score_differences_test.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TexasInstruments/tinyml-tensorlab/3a2d9e8eefdb3ee560d42aa8c01e31eeaf79f166/tinyml-modelmaker/examples/post_training_analysis/arc_fault_dsi/Histogram_Class_Score_differences_test.png -------------------------------------------------------------------------------- /tinyml-modelmaker/examples/post_training_analysis/arc_fault_dsi/One_vs_Rest_MultiClass_ROC_test.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TexasInstruments/tinyml-tensorlab/3a2d9e8eefdb3ee560d42aa8c01e31eeaf79f166/tinyml-modelmaker/examples/post_training_analysis/arc_fault_dsi/One_vs_Rest_MultiClass_ROC_test.png -------------------------------------------------------------------------------- /tinyml-modelmaker/examples/post_training_analysis/arc_fault_dsk/Histogram_Class_Score_differences_test.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TexasInstruments/tinyml-tensorlab/3a2d9e8eefdb3ee560d42aa8c01e31eeaf79f166/tinyml-modelmaker/examples/post_training_analysis/arc_fault_dsk/Histogram_Class_Score_differences_test.png -------------------------------------------------------------------------------- /tinyml-modelmaker/examples/post_training_analysis/arc_fault_dsk/One_vs_Rest_MultiClass_ROC_test.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TexasInstruments/tinyml-tensorlab/3a2d9e8eefdb3ee560d42aa8c01e31eeaf79f166/tinyml-modelmaker/examples/post_training_analysis/arc_fault_dsk/One_vs_Rest_MultiClass_ROC_test.png -------------------------------------------------------------------------------- /tinyml-modelmaker/examples/post_training_analysis/motor_bearing_fault_dsk/Histogram_Class_Score_differences_test.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TexasInstruments/tinyml-tensorlab/3a2d9e8eefdb3ee560d42aa8c01e31eeaf79f166/tinyml-modelmaker/examples/post_training_analysis/motor_bearing_fault_dsk/Histogram_Class_Score_differences_test.png -------------------------------------------------------------------------------- /tinyml-modelmaker/examples/post_training_analysis/motor_bearing_fault_dsk/One_vs_Rest_MultiClass_ROC_test.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TexasInstruments/tinyml-tensorlab/3a2d9e8eefdb3ee560d42aa8c01e31eeaf79f166/tinyml-modelmaker/examples/post_training_analysis/motor_bearing_fault_dsk/One_vs_Rest_MultiClass_ROC_test.png -------------------------------------------------------------------------------- /tinyml-modelmaker/misc/ArcFault_model_x_t.yaml: -------------------------------------------------------------------------------- 1 | input_features: 512 2 | variables: 1 3 | num_classes: 2 4 | stride: 2 5 | num_channel_l1: 4 6 | num_channel: 4 7 | kernel: 4 8 | max_pool: 4 9 | with_input_batchnorm: True 10 | dual_op: False -------------------------------------------------------------------------------- /tinyml-modelmaker/misc/MotorFault_model_x_t.yaml: -------------------------------------------------------------------------------- 1 | input_features: 256 2 | variables: 1 3 | num_classes: 6 4 | stride: 4 5 | num_channel: 8 6 | kernel: 8 7 | max_pool: 7 8 | with_input_batchnorm: True 9 | height: 1 10 | dual_op: False -------------------------------------------------------------------------------- /tinyml-modelmaker/misc/TimeSeries_Generic_x_t.yaml: -------------------------------------------------------------------------------- 1 | input_features: 512 2 | variables: 1 3 | num_classes: 2 4 | with_input_batchnorm: True -------------------------------------------------------------------------------- /tinyml-modelmaker/misc/augmenter_config.yaml: -------------------------------------------------------------------------------- 1 | # Please check tinyml-tinyverse/tinyml_tinyverse/common/augmenters for more details on what augmenters can be used with corresponding arguments 2 | AddNoise: 3 | scale: 0.1 4 | distr: "gaussian" 5 | kind: "additive" 6 | per_channel: True 7 | normalize: True 8 | repeats: 1 9 | prob: 0.9 10 | # TimeWarp: 11 | # n_speed_change: 5 # random time warping 5 times in parallel 12 | # Crop: 13 | # size: 300 # random crop subsequences with length 300 14 | # Quantize: 15 | # n_levels: [10, 20, 30] # random quantize to 10-, 20-, or 30- level sets 16 | # Drift: 17 | # max_drift: 0.1 18 | # prob: 0.8 # with 80% probability, random drift the signal up to 10% 19 | # Reverse: 20 | # prob: 0.5 # with 50% probability, reverse the sequence 21 | -------------------------------------------------------------------------------- /tinyml-modelmaker/misc/tcresnet.yaml: -------------------------------------------------------------------------------- 1 | input_features: 4096 2 | variables: 1 3 | num_classes: 6 4 | stride: 1 5 | num_channel: 32 6 | kernel: 4 7 | max_pool: 4 8 | with_input_batchnorm: True -------------------------------------------------------------------------------- /tinyml-modelmaker/pyproject.toml: -------------------------------------------------------------------------------- 1 | [build-system] 2 | requires = ["setuptools>=42", "wheel"] 3 | build-backend = "setuptools.build_meta" 4 | 5 | [project] 6 | name = "tinyml_modelmaker" 7 | version = "1.0.0" 8 | description = "Tiny ML ModelMaker" 9 | authors = [ 10 | { name = "Adithya Thonse", email = "thonse@ti.com" } 11 | ] 12 | license = { text = "BSD 3-Clause" } 13 | readme = "README.md" 14 | requires-python = "==3.10.*" 15 | classifiers = [ 16 | "Development Status :: 4 - Beta", 17 | "Programming Language :: Python :: 3.10" 18 | ] 19 | dependencies = [ 20 | "defusedxml==0.7.1", 21 | "numpy==1.26.4", 22 | "pandas==2.2.2", 23 | "pathlib2==2.3.7.post1", 24 | "PyYAML==6.0.2", 25 | "tqdm==4.66.5", 26 | "requests==2.32.3", 27 | # "tinyml_tinyverse @ git+ssh://git@bitbucket.itg.ti.com/tinyml-algo/tinyml-tinyverse.git", 28 | "tinyml_tinyverse @ git+https://github.com/TexasInstruments/tinyml-tensorlab.git@main#subdirectory=tinyml-tinyverse", 29 | # TinyVerse 30 | "onnx==1.16.1", 31 | "onnxruntime==1.19.0", 32 | "protobuf==5.27.3", 33 | "pathlib2==2.3.7.post1", 34 | "scipy==1.13.1", 35 | "tabulate==0.9.0", 36 | "torcheval==0.0.7", 37 | "torchinfo==1.8.0", 38 | "cryptography==43.0.1", 39 | "matplotlib==3.9.2", 40 | "scikit-learn==1.5.2", 41 | "torch==2.3.0", 42 | "pycocotools", 43 | "opencv-python", 44 | # "tinyml_torchmodelopt @ git+ssh://git@bitbucket.itg.ti.com/tinyml-algo/tinyml-modeloptimization.git@main#subdirectory=torchmodelopt", 45 | "tinyml_torchmodelopt @ git+https://github.com/TexasInstruments/tinyml-tensorlab.git@main#subdirectory=tinyml-modeloptimization/torchmodelopt", 46 | "ti_mcu_nnc @ https://software-dl.ti.com/mctools/esd/tvm/mcu/ti_mcu_nnc-1.3.0-cp310-cp310-linux_x86_64.whl ; platform_system == 'Linux'", 47 | "ti_mcu_nnc @ https://software-dl.ti.com/mctools/esd/tvm/mcu/ti_mcu_nnc-1.3.0-cp310-cp310-win_amd64.whl ; platform_system == 'Windows'", 48 | # TorchmodelOpt 49 | "Cython==3.0.11", 50 | "protobuf==5.27.3", 51 | "pillow==10.4.0", 52 | "onnxsim==0.4.36", 53 | "onnxsim==0.4.36", 54 | "onnxoptimizer==0.3.13", 55 | "progressbar==2.5", 56 | "rich==13.7.1", 57 | 58 | ] 59 | 60 | [project.urls] 61 | "Homepage" = "https://github.com/TexasInstruments/tinyml-tensorlab/tree/main/tinyml-modelmaker" 62 | 63 | [tool.setuptools] 64 | include-package-data = true 65 | 66 | 67 | [tool.setuptools.packages.find] 68 | include = ["tinyml_modelmaker*"] 69 | exclude = ["tests*"] 70 | 71 | [tool.setuptools.dynamic] 72 | version = {attr = "tinyml_modelmaker.__version__"} 73 | -------------------------------------------------------------------------------- /tinyml-modelmaker/requirements.txt: -------------------------------------------------------------------------------- 1 | defusedxml==0.7.1 2 | numpy==1.26.4 3 | pandas==2.2.2 4 | pathlib2==2.3.7.post1 5 | PyYAML==6.0.2 6 | tqdm==4.66.5 7 | requests==2.32.3 8 | pillow==10.4.0 9 | -------------------------------------------------------------------------------- /tinyml-modelmaker/run_tinyml_modelmaker.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ################################################################################# 4 | if [ $# -le 1 ]; then 5 | echo "help:" 6 | echo "$0 target_device config_file" 7 | exit 0 8 | fi 9 | 10 | ################################################################################# 11 | HOME_DIR=${HOME} 12 | HOME_DIR=$(realpath $HOME_DIR) 13 | 14 | WORK_DIR=${WORK_DIR:-"./"} 15 | DATA_DIR=${WORK_DIR:-"./data"} 16 | 17 | export TOOLS_PATH=${TOOLS_PATH:-$HOME_DIR/bin} 18 | 19 | TARGET_SOC=${1:-F28P55} 20 | CONFIG_FILE=${2:-config_timeseries_classification_kilby.yaml} 21 | 22 | ################################################################################# 23 | export PYTHONPATH=.:$PYTHONPATH 24 | 25 | ################################################################################# 26 | # print some settings 27 | echo "Target device : ${TARGET_SOC}" 28 | echo "PYTHONPATH : ${PYTHONPATH}" 29 | 30 | ################################################################################# 31 | python tinyml_modelmaker/run_tinyml_modelmaker.py ${CONFIG_FILE} --target_device ${TARGET_SOC} 32 | -------------------------------------------------------------------------------- /tinyml-modelmaker/scripts/get_model_performance_data.py: -------------------------------------------------------------------------------- 1 | import pandas as pd 2 | from pprint import PrettyPrinter 3 | from tinyml_modelmaker.ai_modules.timeseries import constants 4 | 5 | valid_model_list = ['MotorFault_model_1_t', 'MotorFault_model_2_t', 'MotorFault_model_3_t', 6 | 'ArcFault_model_200_t', 'ArcFault_model_300_t', 'ArcFault_model_700_t', 'ArcFault_model_1400_t', 7 | 'TimeSeries_Generic_1k_t', 'TimeSeries_Generic_4k_t', 'TimeSeries_Generic_6k_t', 8 | 'TimeSeries_Generic_13k_t', ] 9 | soft_tinie_targets = ['c28_soft_int_in_int_out'] 10 | hard_tinie_targets = ['c28_hard_int_in_int_out'] 11 | valid_tinie_targets = soft_tinie_targets + hard_tinie_targets 12 | 13 | url = 'https://jenkins-sdomc.dal.design.ti.com/job/build-tinie-tests/lastSuccessfulBuild/artifact/tinie-tests/testing/ti_tests.log' 14 | tvm_results_df = pd.read_csv(url, sep="\s+|\:|\,|\+|\=", engine='python', skiprows=1, 15 | header=None).dropna(axis=1).drop(columns=[3, 6, 13]) 16 | relevant_df = tvm_results_df.loc[tvm_results_df[0].isin(valid_model_list) & tvm_results_df[1].isin(valid_tinie_targets)] 17 | relevant_df.columns = ['model', 'target_tinie_type', 'cycles', 'code', 'ro', 'rw', 'total'] 18 | 19 | # Now convert c28_soft_int_in_int_out to 2 columns having c28 and soft while removing int_in_int_out 20 | relevant_df['target_tinie_type'] = relevant_df['target_tinie_type'].str.split('_').str[:2].str.join('_') 21 | relevant_df[['target', 'tinie_type']] = relevant_df['target_tinie_type'].str.split('_', expand=True) 22 | 23 | # Do a few calculations and add relevant columns 24 | # relevant_df['inference_time_us'] = relevant_df['cycles'] // 150 # P55 by default runs at 150MHz, dividing by 150 because we report time in us (not seconds) 25 | relevant_df['flash'] = relevant_df['ro'] + relevant_df['code'] 26 | relevant_df['sram'] = relevant_df['rw'] 27 | relevant_df = relevant_df.drop(columns=['target_tinie_type', 'code', 'ro', 'rw', 'total']) 28 | relevant_df = relevant_df.set_index(['model']) # 'cycles', 29 | # relevant_df = relevant_df.set_index(['model', 'target', 'tinie_type']) # 'cycles', 30 | 31 | device_list = [constants.TARGET_DEVICE_F280015, constants.TARGET_DEVICE_F28003, constants.TARGET_DEVICE_F28004, 32 | constants.TARGET_DEVICE_F2837, constants.TARGET_DEVICE_F28P65] 33 | freq_MHz_dict = { 34 | constants.TARGET_DEVICE_F280015: 120, 35 | constants.TARGET_DEVICE_F28003: 120, 36 | constants.TARGET_DEVICE_F28004: 100, 37 | constants.TARGET_DEVICE_F2837: 120, 38 | constants.TARGET_DEVICE_F28P65: 200, 39 | constants.TARGET_DEVICE_F28P55: 150, 40 | } 41 | 42 | scaling_factors_dict = {k:v/freq_MHz_dict[constants.TARGET_DEVICE_F28P55] for k, v in freq_MHz_dict.items()} 43 | 44 | 45 | # Convert CPU Cycles to microseconds. Data was collected by running on F28P55 46 | relevant_df['inference_time_us'] = (relevant_df['cycles']/freq_MHz_dict[constants.TARGET_DEVICE_F28P55]).astype(int) 47 | relevant_df = relevant_df.drop(columns=['cycles']) 48 | 49 | hard_tinie_df = relevant_df.loc[relevant_df.tinie_type=='hard'] 50 | hard_tinie_df['device'] = constants.TARGET_DEVICE_F28P55 51 | 52 | soft_tinie_df = relevant_df.loc[relevant_df.tinie_type=='soft'] 53 | soft_tinie_df['device'] = [device_list for i in soft_tinie_df.index] 54 | soft_tinie_df = soft_tinie_df.explode('device') 55 | soft_tinie_df['inference_time_us'] = (soft_tinie_df['inference_time_us'] * soft_tinie_df['device'].map(scaling_factors_dict)).astype(int) 56 | 57 | device_info_df = pd.concat((soft_tinie_df, hard_tinie_df)).drop(columns=['tinie_type', 'target']).reset_index() # .reset_index().set_index(['model', 'device']) 58 | device_info_dict = {model: {device: {col: group[col].values[0] for col in ['inference_time_us', 'sram', 'flash']} for device, group in sub_group.groupby('device')} for model, sub_group in device_info_df.groupby('model')} 59 | """ 60 | The above dict comprehension is to get this structure 61 | 62 | 'motor_fault_3_t': {'F280015': {'flash': 2552, 63 | 'inference_time_us': 552, 64 | 'sram': 1158}, 65 | 'F28003': {'flash': 2552, 66 | 'inference_time_us': 552, 67 | 'sram': 1158}, ... 68 | """ 69 | print("Please copy the below dictionary to the relevant py script (Example: device_run_info.py)") 70 | print(PrettyPrinter(depth=3).pprint(device_info_dict)) 71 | -------------------------------------------------------------------------------- /tinyml-modelmaker/setup.py: -------------------------------------------------------------------------------- 1 | from setuptools import setup 2 | 3 | if __name__ == '__main__': 4 | setup() 5 | # import os 6 | # import subprocess 7 | # 8 | # from setuptools import find_packages, setup 9 | # 10 | # 11 | # def git_hash(): 12 | # git_path = '.' if os.path.exists('.git') else ('..' if os.path.exists(os.path.join('..', '.git')) else None) 13 | # if git_path: 14 | # hash = subprocess.check_output(['git', 'rev-parse', 'HEAD']).strip() 15 | # return hash[:7] if (hash is not None) else None 16 | # else: 17 | # return None 18 | # 19 | # 20 | # def get_version(): 21 | # # from version import __version__ 22 | # __version__ = '1.0.0' 23 | # hash = git_hash() 24 | # version_str = __version__ + '+' + hash.strip().decode('ascii') if (hash is not None) else __version__ 25 | # return version_str 26 | # 27 | # 28 | # if __name__ == '__main__': 29 | # version_str = get_version() 30 | # 31 | # long_description = '' 32 | # with open('README.md', encoding="utf8") as readme: 33 | # long_description = readme.read() 34 | # 35 | # setup( 36 | # name='tinyml_modelmaker', 37 | # version=get_version(), 38 | # description='Tiny ML ModelMaker', 39 | # long_description=long_description, 40 | # long_description_content_type='text/markdown', 41 | # url='https://github.com/TexasInstruments/tinyml-tensorlab/tree/main/tinyml-modelmaker', 42 | # author='Adithya Thonse', 43 | # author_email='thonse@ti.com', 44 | # classifiers=[ 45 | # 'Development Status :: 1 - Beta' 46 | # 'Programming Language :: Python :: 3.10' 47 | # ], 48 | # keywords = 'artifical intelligence, deep learning, image classification, visual wake words, time series classsification, audio keyword spotting', 49 | # python_requires='>=3.10', 50 | # packages=find_packages(), 51 | # include_package_data=True, 52 | # install_requires=[], 53 | # project_urls={ 54 | # 'Source': 'https://github.com/TexasInstruments/tinyml-tensorlab/tree/main/tinyml-modelmaker', 55 | # 'Bug Reports': 'https://e2e.ti.com/support/processors/', 56 | # }, 57 | # ) 58 | 59 | -------------------------------------------------------------------------------- /tinyml-modelmaker/setup.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Copyright (c) 2023-2024, Texas Instruments 4 | # All Rights Reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are met: 8 | # 9 | # * Redistributions of source code must retain the above copyright notice, this 10 | # list of conditions and the following disclaimer. 11 | # 12 | # * Redistributions in binary form must reproduce the above copyright notice, 13 | # this list of conditions and the following disclaimer in the documentation 14 | # and/or other materials provided with the distribution. 15 | # 16 | # * Neither the name of the copyright holder nor the names of its 17 | # contributors may be used to endorse or promote products derived from 18 | # this software without specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | ###################################################################### 32 | # Installing dependencies 33 | echo 'Installing python packages...' 34 | python -m pip install --no-input -r requirements.txt 35 | 36 | ###################################################################### 37 | echo 'Installing as a local module using setup.py' 38 | python -m pip install --editable . --use-pep517 39 | -------------------------------------------------------------------------------- /tinyml-modelmaker/setup_armclang_tools.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ################################################################################# 4 | # Copyright (c) 2018-2024, Texas Instruments Incorporated - http://www.ti.com 5 | # All Rights Reserved. 6 | # 7 | # Redistribution and use in source and binary forms, with or without 8 | # modification, are permitted provided that the following conditions are met: 9 | # 10 | # * Redistributions of source code must retain the above copyright notice, this 11 | # list of conditions and the following disclaimer. 12 | # 13 | # * Redistributions in binary form must reproduce the above copyright notice, 14 | # this list of conditions and the following disclaimer in the documentation 15 | # and/or other materials provided with the distribution. 16 | # 17 | # * Neither the name of the copyright holder nor the names of its 18 | # contributors may be used to endorse or promote products derived from 19 | # this software without specific prior written permission. 20 | # 21 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 25 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 28 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | # 32 | ################################################################################# 33 | 34 | HOME_DIR=${HOME} 35 | HOME_DIR=$(realpath $HOME_DIR) 36 | 37 | INSTALLER_PATH=${INSTALLER_PATH:-$HOME_DIR/installer} 38 | TOOLS_PATH=${TOOLS_PATH:-$HOME_DIR/bin} 39 | mkdir -p ${INSTALLER_PATH} 40 | mkdir -p ${TOOLS_PATH} 41 | 42 | ################################################################################# 43 | # ARM clang cgtools 44 | 45 | ARM_CGT_CLANG_INSTALLER=ti_cgt_armllvm_4.0.3.LTS_linux-x64_installer.bin 46 | ARM_CGT_CLANG_INSTALLER_FILE=${INSTALLER_PATH}/${ARM_CGT_CLANG_INSTALLER} 47 | rm -f ${ARM_CGT_CLANG_INSTALLER_FILE} 48 | wget https://dr-download.ti.com/software-development/ide-configuration-compiler-or-debugger/MD-ayxs93eZNN/4.0.3.LTS/${ARM_CGT_CLANG_INSTALLER} -O ${ARM_CGT_CLANG_INSTALLER_FILE} 49 | chmod +x ${ARM_CGT_CLANG_INSTALLER_FILE} 50 | ${ARM_CGT_CLANG_INSTALLER_FILE} --mode unattended --prefix ${TOOLS_PATH} 51 | rm -f ${ARM_CGT_CLANG_INSTALLER_FILE} 52 | -------------------------------------------------------------------------------- /tinyml-modelmaker/setup_c2000ware.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ################################################################################# 4 | # Copyright (c) 2018-2024, Texas Instruments Incorporated - http://www.ti.com 5 | # All Rights Reserved. 6 | # 7 | # Redistribution and use in source and binary forms, with or without 8 | # modification, are permitted provided that the following conditions are met: 9 | # 10 | # * Redistributions of source code must retain the above copyright notice, this 11 | # list of conditions and the following disclaimer. 12 | # 13 | # * Redistributions in binary form must reproduce the above copyright notice, 14 | # this list of conditions and the following disclaimer in the documentation 15 | # and/or other materials provided with the distribution. 16 | # 17 | # * Neither the name of the copyright holder nor the names of its 18 | # contributors may be used to endorse or promote products derived from 19 | # this software without specific prior written permission. 20 | # 21 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 25 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 28 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | # 32 | ################################################################################# 33 | 34 | HOME_DIR=${HOME} 35 | HOME_DIR=$(realpath $HOME_DIR) 36 | 37 | INSTALLER_PATH=${INSTALLER_PATH:-$HOME_DIR/installer} 38 | TOOLS_PATH=${TOOLS_PATH:-$HOME_DIR/bin} 39 | mkdir -p ${INSTALLER_PATH} 40 | mkdir -p ${TOOLS_PATH} 41 | 42 | # multiarch i386 is needed for c2000ware 43 | sudo apt update 44 | sudo apt install -y binutils-multiarch binutils 45 | sudo dpkg --add-architecture i386 46 | sudo apt update 47 | sudo apt install -y binutils:i386 48 | 49 | ################################################################################# 50 | 51 | # now install c2000ware 52 | C2000WARE_INSTALLER=C2000Ware_5_04_00_00_setup.run 53 | C2000WARE_INSTALLER_FILE=${INSTALLER_PATH}/${C2000WARE_INSTALLER} 54 | # rm -f ${C2000WARE_INSTALLER_FILE} 55 | wget http://c2000-ubuntu-build-pc.dhcp.ti.com/c2000ware-builds/5.04.00.00/RC4/${C2000WARE_INSTALLER} -O ${C2000WARE_INSTALLER_FILE} 56 | if [ -e ${C2000WARE_INSTALLER_FILE} ]; then 57 | echo -e "\033[0;32mDownloaded ${C2000WARE_INSTALLER_FILE} from TI remote repository!\033[0m" 58 | chmod +x ${C2000WARE_INSTALLER_FILE} 59 | ${C2000WARE_INSTALLER_FILE} --mode unattended --prefix ${TOOLS_PATH} 60 | rm -f ${C2000WARE_INSTALLER_FILE} 61 | else 62 | echo -e "\033[31;5mCRITICAL WARNING! C2000Ware could not be downloaded! \033[0m" # Blinking Text 63 | echo -e "\033[0;33mPlease note that C2000Ware requires SW Export License permissions. \033[0m" 64 | echo -e "\033[0;33mIf you are installing this outside TI network, then you will need to separately download the Linux version: ${C2000WARE_INSTALLER} from: https://www.ti.com/tool/download/C2000WARE/ \033[0m" 65 | echo -e "\033[0;33mAnd then run the following 2 commands:\033[0m" 66 | echo "chmod +x ${C2000WARE_INSTALLER}" 67 | echo "${C2000WARE_INSTALLER} --mode unattended --prefix ${TOOLS_PATH}" 68 | echo -e "\033[0;33mPlease hit Ctrl+C repeatedly and manually download the C2000Ware and install it. \033[0m" 69 | echo -e "\033[0;33mContinuing installation nevertheless- meaning you can do AI training, but not model compilation. \033[0m" 70 | echo -e "\033[0;32mIgnore the above messages if you have already manually installed C2000Ware \033[0m" 71 | echo -e "\033[33;5mWaiting for 90 seconds to let you make a decision.\033[0m" 72 | sleep 90 73 | fi 74 | 75 | sudo apt update && sudo apt install -y binutils g++ gcc 76 | -------------------------------------------------------------------------------- /tinyml-modelmaker/setup_cg_tools.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ################################################################################# 4 | # Copyright (c) 2018-2024, Texas Instruments Incorporated - http://www.ti.com 5 | # All Rights Reserved. 6 | # 7 | # Redistribution and use in source and binary forms, with or without 8 | # modification, are permitted provided that the following conditions are met: 9 | # 10 | # * Redistributions of source code must retain the above copyright notice, this 11 | # list of conditions and the following disclaimer. 12 | # 13 | # * Redistributions in binary form must reproduce the above copyright notice, 14 | # this list of conditions and the following disclaimer in the documentation 15 | # and/or other materials provided with the distribution. 16 | # 17 | # * Neither the name of the copyright holder nor the names of its 18 | # contributors may be used to endorse or promote products derived from 19 | # this software without specific prior written permission. 20 | # 21 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 25 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 28 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | # 32 | ################################################################################# 33 | 34 | HOME_DIR=${HOME} 35 | HOME_DIR=$(realpath $HOME_DIR) 36 | 37 | INSTALLER_PATH=${INSTALLER_PATH:-$HOME_DIR/installer} 38 | TOOLS_PATH=${TOOLS_PATH:-$HOME_DIR/bin} 39 | mkdir -p ${INSTALLER_PATH} 40 | mkdir -p ${TOOLS_PATH} 41 | 42 | ################################################################################# 43 | # c2000 cgtools 44 | C2000_CGT_INSTALLER=ti_cgt_c2000_22.6.1.LTS_linux-x64_installer.bin 45 | C2000_CGT_INSTALLER_FILE=${INSTALLER_PATH}/${C2000_CGT_INSTALLER} 46 | rm -f ${C2000_CGT_INSTALLER_FILE} 47 | wget https://dr-download.ti.com/software-development/ide-configuration-compiler-or-debugger/MD-xqxJ05PLfM/22.6.1.LTS/${C2000_CGT_INSTALLER} -O ${C2000_CGT_INSTALLER_FILE} 48 | chmod +x ${C2000_CGT_INSTALLER_FILE} 49 | ${C2000_CGT_INSTALLER_FILE} --mode unattended --prefix ${TOOLS_PATH} 50 | rm -f ${C2000_CGT_INSTALLER_FILE} 51 | -------------------------------------------------------------------------------- /tinyml-modelmaker/tinyml_modelmaker/__init__.py: -------------------------------------------------------------------------------- 1 | ################################################################################# 2 | # Copyright (c) 2023-2024, Texas Instruments 3 | # All Rights Reserved. 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions are met: 7 | # 8 | # * Redistributions of source code must retain the above copyright notice, this 9 | # list of conditions and the following disclaimer. 10 | # 11 | # * Redistributions in binary form must reproduce the above copyright notice, 12 | # this list of conditions and the following disclaimer in the documentation 13 | # and/or other materials provided with the distribution. 14 | # 15 | # * Neither the name of the copyright holder nor the names of its 16 | # contributors may be used to endorse or promote products derived from 17 | # this software without specific prior written permission. 18 | # 19 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 20 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 23 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 26 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 27 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | ################################################################################# 30 | 31 | from . import ai_modules 32 | from .run_tinyml_modelmaker import main as get_set_go 33 | 34 | 35 | def get_task_category_type_from_task_type(task_type): 36 | task_type_to_task_category_type_map = { 37 | ai_modules.timeseries.constants.TASK_TYPE_ARC_FAULT: ai_modules.timeseries.constants.TASK_CATEGORY_TS_CLASSIFICATION, 38 | ai_modules.timeseries.constants.TASK_TYPE_MOTOR_FAULT: ai_modules.timeseries.constants.TASK_CATEGORY_TS_CLASSIFICATION, 39 | ai_modules.timeseries.constants.TASK_TYPE_BLOWER_IMBALANCE: ai_modules.timeseries.constants.TASK_CATEGORY_TS_CLASSIFICATION, 40 | ai_modules.timeseries.constants.TASK_TYPE_GENERIC_TS_CLASSIFICATION: ai_modules.timeseries.constants.TASK_CATEGORY_TS_CLASSIFICATION, 41 | ai_modules.timeseries.constants.TASK_TYPE_GENERIC_TS_REGRESSION: ai_modules.timeseries.constants.TASK_CATEGORY_TS_REGRESSION, 42 | ai_modules.timeseries.constants.TASK_TYPE_GENERIC_TS_ANOMALYDETECTION: ai_modules.timeseries.constants.TASK_CATEGORY_TS_ANOMALYDETECTION, 43 | } 44 | return task_type_to_task_category_type_map.get(task_type) 45 | -------------------------------------------------------------------------------- /tinyml-modelmaker/tinyml_modelmaker/ai_modules/__init__.py: -------------------------------------------------------------------------------- 1 | ################################################################################# 2 | # Copyright (c) 2023-2024, Texas Instruments 3 | # All Rights Reserved. 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions are met: 7 | # 8 | # * Redistributions of source code must retain the above copyright notice, this 9 | # list of conditions and the following disclaimer. 10 | # 11 | # * Redistributions in binary form must reproduce the above copyright notice, 12 | # this list of conditions and the following disclaimer in the documentation 13 | # and/or other materials provided with the distribution. 14 | # 15 | # * Neither the name of the copyright holder nor the names of its 16 | # contributors may be used to endorse or promote products derived from 17 | # this software without specific prior written permission. 18 | # 19 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 20 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 23 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 26 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 27 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | ################################################################################# 30 | 31 | import sys 32 | from . import timeseries 33 | 34 | 35 | def get_target_module(backend_name): 36 | this_module = sys.modules[__name__] 37 | target_module = getattr(this_module, backend_name) 38 | return target_module 39 | -------------------------------------------------------------------------------- /tinyml-modelmaker/tinyml_modelmaker/ai_modules/common/__init__.py: -------------------------------------------------------------------------------- 1 | ################################################################################# 2 | # Copyright (c) 2023-2024, Texas Instruments 3 | # All Rights Reserved. 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions are met: 7 | # 8 | # * Redistributions of source code must retain the above copyright notice, this 9 | # list of conditions and the following disclaimer. 10 | # 11 | # * Redistributions in binary form must reproduce the above copyright notice, 12 | # this list of conditions and the following disclaimer in the documentation 13 | # and/or other materials provided with the distribution. 14 | # 15 | # * Neither the name of the copyright holder nor the names of its 16 | # contributors may be used to endorse or promote products derived from 17 | # this software without specific prior written permission. 18 | # 19 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 20 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 23 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 26 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 27 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | ################################################################################# 30 | 31 | -------------------------------------------------------------------------------- /tinyml-modelmaker/tinyml_modelmaker/ai_modules/common/compilation/__init__.py: -------------------------------------------------------------------------------- 1 | ################################################################################# 2 | # Copyright (c) 2023-2024, Texas Instruments 3 | # All Rights Reserved. 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions are met: 7 | # 8 | # * Redistributions of source code must retain the above copyright notice, this 9 | # list of conditions and the following disclaimer. 10 | # 11 | # * Redistributions in binary form must reproduce the above copyright notice, 12 | # this list of conditions and the following disclaimer in the documentation 13 | # and/or other materials provided with the distribution. 14 | # 15 | # * Neither the name of the copyright holder nor the names of its 16 | # contributors may be used to endorse or promote products derived from 17 | # this software without specific prior written permission. 18 | # 19 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 20 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 23 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 26 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 27 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | ################################################################################# 30 | 31 | from . import tinyml_benchmark 32 | 33 | -------------------------------------------------------------------------------- /tinyml-modelmaker/tinyml_modelmaker/ai_modules/timeseries/__init__.py: -------------------------------------------------------------------------------- 1 | ################################################################################# 2 | # Copyright (c) 2023-2024, Texas Instruments 3 | # All Rights Reserved. 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions are met: 7 | # 8 | # * Redistributions of source code must retain the above copyright notice, this 9 | # list of conditions and the following disclaimer. 10 | # 11 | # * Redistributions in binary form must reproduce the above copyright notice, 12 | # this list of conditions and the following disclaimer in the documentation 13 | # and/or other materials provided with the distribution. 14 | # 15 | # * Neither the name of the copyright holder nor the names of its 16 | # contributors may be used to endorse or promote products derived from 17 | # this software without specific prior written permission. 18 | # 19 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 20 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 23 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 26 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 27 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | ################################################################################# 30 | 31 | from . import constants, datasets, runner, training 32 | -------------------------------------------------------------------------------- /tinyml-modelmaker/tinyml_modelmaker/ai_modules/timeseries/compilation/__init__.py: -------------------------------------------------------------------------------- 1 | from ...common.compilation import tinyml_benchmark 2 | 3 | -------------------------------------------------------------------------------- /tinyml-modelmaker/tinyml_modelmaker/ai_modules/timeseries/datasets/__init__.py: -------------------------------------------------------------------------------- 1 | from ...common.datasets import DatasetHandling 2 | 3 | -------------------------------------------------------------------------------- /tinyml-modelmaker/tinyml_modelmaker/ai_modules/timeseries/training/tinyml_tinyverse/__init__.py: -------------------------------------------------------------------------------- 1 | ################################################################################# 2 | # Copyright (c) 2023-2024, Texas Instruments 3 | # All Rights Reserved. 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions are met: 7 | # 8 | # * Redistributions of source code must retain the above copyright notice, this 9 | # list of conditions and the following disclaimer. 10 | # 11 | # * Redistributions in binary form must reproduce the above copyright notice, 12 | # this list of conditions and the following disclaimer in the documentation 13 | # and/or other materials provided with the distribution. 14 | # 15 | # * Neither the name of the copyright holder nor the names of its 16 | # contributors may be used to endorse or promote products derived from 17 | # this software without specific prior written permission. 18 | # 19 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 20 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 23 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 26 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 27 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | ################################################################################# 30 | 31 | -------------------------------------------------------------------------------- /tinyml-modelmaker/tinyml_modelmaker/utils/__init__.py: -------------------------------------------------------------------------------- 1 | from .config_dict import * 2 | from .misc_utils import * 3 | from .download_utils import * 4 | # from . import mdcl_utils 5 | -------------------------------------------------------------------------------- /tinyml-modelmaker/tinyml_modelmaker/version.py: -------------------------------------------------------------------------------- 1 | ################################################################################# 2 | # Copyright (c) 2023-2024, Texas Instruments 3 | # All Rights Reserved. 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions are met: 7 | # 8 | # * Redistributions of source code must retain the above copyright notice, this 9 | # list of conditions and the following disclaimer. 10 | # 11 | # * Redistributions in binary form must reproduce the above copyright notice, 12 | # this list of conditions and the following disclaimer in the documentation 13 | # and/or other materials provided with the distribution. 14 | # 15 | # * Neither the name of the copyright holder nor the names of its 16 | # contributors may be used to endorse or promote products derived from 17 | # this software without specific prior written permission. 18 | # 19 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 20 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 23 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 26 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 27 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | ################################################################################# 30 | 31 | __version__ = '1.0.0' 32 | 33 | 34 | def get_version(): 35 | return __version__ 36 | 37 | 38 | def get_version_str(delimiter='_'): 39 | version_str = delimiter.join([f'{r:0>2}' for r in __version__.split('.')]) 40 | return version_str 41 | -------------------------------------------------------------------------------- /tinyml-modeloptimization/.gitignore: -------------------------------------------------------------------------------- 1 | torchmodelopt/examples/audio_keyword_spotting/SpeechCommands/ 2 | *.pyc 3 | *.egg-info 4 | *.onnx -------------------------------------------------------------------------------- /tinyml-modeloptimization/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2023-2024, Texas Instruments Incorporated 2 | All Rights Reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | * Neither the name of the copyright holder nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 25 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /tinyml-modeloptimization/README.md: -------------------------------------------------------------------------------- 1 | # Tiny ML Torch Model Optimization Repository 2 | 3 | 4 | ## Tiny ML TorchModelOpt 5 | * [Tiny ML TorchModelOpt Documentation](./torchmodelopt/) - Tools and utilities to help the development of embedded friendly DNN(Deep Neural Network) Models in [Pytorch](https://pytorch.org) - we call these **model optimization tools**. 6 | * This repository helps you to quantize (with Quantization Aware Training - QAT) your model to formats that can run optimally on TI's MCUs 7 | * Examples for using this repository is present at [examples](./torchmodelopt/examples/) 8 | -------------------------------------------------------------------------------- /tinyml-modeloptimization/torchmodelopt/examples/README.md: -------------------------------------------------------------------------------- 1 | # Tiny ML Model Optimization 2 | 3 | ## Overview 4 | 5 | Tiny ML Model Optimization is the toolkit for optimizing models. It offers an extensive set of operations to boost your model performance. In life cycle of model, from training, optimizing to deploying and inference, this repository helps in the optimization phase. 6 | 7 | The key features of Model Optimization: 8 | 9 | **Basic** 10 | - 8bit/4bit/2bit quantization 11 | - Quantization Aware Training / Post Training Quantization 12 | - Convert modules to leverage TI's NPU power 13 | - Perform Inference on exported ONNX 14 | 15 | **Advanced** 16 | - Mixed Precision 17 | - Calibrating Bias with Bias Calibration Factor 18 | 19 | Using the tinyml-modeloptimization toolkit can be challenging and overwhelming for users. The example directory is designed to help users get started, guiding them from basic to advanced usage. 20 | 21 | | Example | Dataset | Description | 22 | |:-----------------------:|:---------------:| :----: | 23 | |[Image classification](./fmnist_image_classification)|[Fashion MNIST Dataset](https://pytorch.org/vision/stable/generated/torchvision.datasets.FashionMNIST.html) | Simple Example, Dataloader from torch.datasets, LinearRelu NN Model, QAT, Supports TI-NPU, Renaming node, ONNX Inference | 24 | |[Time series classification](./motor_fault_time_series_classification)| [Motor Fault Dataset](./motor_fault_time_series_classification/motor_fault_dataset.csv) | Dataloader from CSV, QAT/PTQ, 2b/4b/8b Weights, CNN Model, ONNX Inference | 25 | |[Audio Keyword Spotting](./audio_keyword_spotting)| [SpeechCommands Dataset](https://www.tensorflow.org/datasets/catalog/speech_commands) | Extensive Example, Dataloader from tensorflow dataset, DSCNN Model, Perform PTQ, Mixed Precision, Bias Calibration | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /tinyml-modeloptimization/torchmodelopt/examples/audio_keyword_spotting/quant_cal_indices_mlperf.txt: -------------------------------------------------------------------------------- 1 | 3857 2 | 28 3 | 8255 4 | 8182 5 | 9497 6 | 593 7 | 3404 8 | 527 9 | 110 10 | 405 11 | 1877 12 | 2147 13 | 9455 14 | 5992 15 | 5548 16 | 5485 17 | 9069 18 | 5954 19 | 6467 20 | 2782 21 | 9828 22 | 8701 23 | 8727 24 | 10045 25 | 3122 26 | 222 27 | 4932 28 | 3226 29 | 10019 30 | 4969 31 | 4490 32 | 5500 33 | 1759 34 | 2003 35 | 5636 36 | 2367 37 | 6728 38 | 406 39 | 587 40 | 2174 41 | 2413 42 | 1959 43 | 2451 44 | 1884 45 | 8880 46 | 1595 47 | 7939 48 | 2510 49 | 5220 50 | 754 51 | 2466 52 | 5481 53 | 5233 54 | 51 55 | 7038 56 | 8749 57 | 9843 58 | 5170 59 | 6172 60 | 1842 61 | 5796 62 | 3053 63 | 3354 64 | 4706 65 | 5167 66 | 3962 67 | 9708 68 | 5740 69 | 581 70 | 6820 71 | 4542 72 | 1187 73 | 8050 74 | 2580 75 | 5181 76 | 3568 77 | 2507 78 | 4738 79 | 1518 80 | 8282 81 | 1957 82 | 9254 83 | 1643 84 | 3023 85 | 1489 86 | 3950 87 | 3444 88 | 2263 89 | 7792 90 | 7712 91 | 9553 92 | 6093 93 | 2188 94 | 3941 95 | 9932 96 | 5985 97 | 6681 98 | 2327 99 | 1034 100 | 1150 101 | 3684 102 | 3981 103 | 4829 104 | 1120 105 | 3351 106 | 6895 107 | 3396 108 | 3188 109 | 4851 110 | 8360 111 | 8553 112 | 5513 113 | 2173 114 | 3450 115 | 4872 116 | 7547 117 | 5173 118 | 4994 119 | 4525 120 | 331 121 | -------------------------------------------------------------------------------- /tinyml-modeloptimization/torchmodelopt/examples/audio_keyword_spotting/requirements.txt: -------------------------------------------------------------------------------- 1 | pydub==0.25.1 2 | torchmetrics 3 | tqdm==4.67.1 4 | tensorflow==2.18.0 5 | soundfile==0.13.1 6 | librosa==0.10.2.post1 7 | torchaudio==2.3.0 8 | scipy==1.15.2 9 | typing_extensions==4.12.2 10 | onnx2torch 11 | pandas 12 | colorama -------------------------------------------------------------------------------- /tinyml-modeloptimization/torchmodelopt/examples/audio_keyword_spotting/trained_models/kws_dscnn_pb2pth_checkpoint.pth: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TexasInstruments/tinyml-tensorlab/3a2d9e8eefdb3ee560d42aa8c01e31eeaf79f166/tinyml-modeloptimization/torchmodelopt/examples/audio_keyword_spotting/trained_models/kws_dscnn_pb2pth_checkpoint.pth -------------------------------------------------------------------------------- /tinyml-modeloptimization/torchmodelopt/examples/audio_keyword_spotting/trained_models/kws_dscnn_pb2pth_metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "initializers.onnx_initializer_2":"fc6.weight", 3 | "initializers.onnx_initializer_3":"fc6.bias", 4 | "StatefulPartitionedCall/functional_1/conv2d/BiasAdd.1.weight":"conv1.weight", 5 | "StatefulPartitionedCall/functional_1/conv2d/BiasAdd.1.bias":"conv1.bias", 6 | "Conv__95.weight":"depthwise2.weight", 7 | "Conv__95.bias":"depthwise2.bias", 8 | "StatefulPartitionedCall/functional_1/conv2d_1/BiasAdd.weight":"pointwise2.weight", 9 | "StatefulPartitionedCall/functional_1/conv2d_1/BiasAdd.bias":"pointwise2.bias", 10 | "Conv__97.weight":"depthwise3.weight", 11 | "Conv__97.bias":"depthwise3.bias", 12 | "StatefulPartitionedCall/functional_1/conv2d_2/BiasAdd.weight":"pointwise3.weight", 13 | "StatefulPartitionedCall/functional_1/conv2d_2/BiasAdd.bias":"pointwise3.bias", 14 | "Conv__99.weight":"depthwise4.weight", 15 | "Conv__99.bias":"depthwise4.bias", 16 | "StatefulPartitionedCall/functional_1/conv2d_3/BiasAdd.weight":"pointwise4.weight", 17 | "StatefulPartitionedCall/functional_1/conv2d_3/BiasAdd.bias":"pointwise4.bias", 18 | "Conv__101.weight":"depthwise5.weight", 19 | "Conv__101.bias":"depthwise5.bias", 20 | "StatefulPartitionedCall/functional_1/conv2d_4/BiasAdd.weight":"pointwise5.weight", 21 | "StatefulPartitionedCall/functional_1/conv2d_4/BiasAdd.bias":"pointwise5.bias" 22 | } -------------------------------------------------------------------------------- /tinyml-modeloptimization/torchmodelopt/examples/audio_keyword_spotting/trained_models/kws_dscnn_pb2pth_model.pth: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TexasInstruments/tinyml-tensorlab/3a2d9e8eefdb3ee560d42aa8c01e31eeaf79f166/tinyml-modeloptimization/torchmodelopt/examples/audio_keyword_spotting/trained_models/kws_dscnn_pb2pth_model.pth -------------------------------------------------------------------------------- /tinyml-modeloptimization/torchmodelopt/examples/fmnist_image_classification/README.md: -------------------------------------------------------------------------------- 1 | # FMNIST Image Classification 2 | 3 | FMNIST is fashion MNIST dataset comprises of 60000 training and 10000 testing samples. The dataset is classified in 10 classes. In this example we use a classification model. The model comprises of combination of Linear Relu layers. This is a beginner friendly example to get started on using Tiny ML Model Optimization. 4 | 5 | ## Walkthrough of this Example 6 | 1. Create train and test dataloader from torch.datasets 7 | 2. Create a classification Neural Network 8 | 3. Train and test the model on dataloader 9 | 4. Wrap the trained model around TINPUTinyMLQATFxModule 10 | 5. Train and test this ti_model for QAT 11 | 6. Export the quantized model 12 | 7. Rename the input node of model 13 | 8. Save the ONNX model 14 | 15 | ## Let's understand each step 16 | 17 | ### Prepare Dataloader 18 | - Download the FMNIST dataset from torch.datasets. For training and testing we need two dataloader, one will be train_dataloader and another will be test_dataloader. 19 | - We define the batch size of these dataloader. 20 | 21 | ### Neural Network 22 | - Create a simple neural network comprising of linear and relu layers. Lets call this multiple linear and relu layers as linear_relu_stack. 23 | - The linear_relu_stack expects the input to be the flattened image shape and output is the number of classes. 24 | 25 | ### Train and Test Model 26 | - Loss function: nn.CrossEntropyLoss() 27 | - Optimizer: torch.optim.SGD() 28 | - The model is trained and tested for 5 epochs. The model is then evaluated on test dataloader. After evaluation the model is exported with name as "fmnist.onnx". 29 | 30 | ### TINPUTinyMLQATFxModule wrapper 31 | Coming to the main part of the example. 32 | 33 | - Wrap the trained neural network with **TINPUTinyMLQATFxModule** and the number of epochs the QAT will be trained for. 34 | 35 | ### Train and Test ti_model 36 | - With the same Loss function and optimizer, train and test the wrapped ti model with respective dataloader. 37 | 38 | ### Export ti_model 39 | - Convert the ti_model from pytorch qdq layers to TI NPU int8 layers. 40 | - Export the ti_model from TI NPU int8 layers to onnx with name as "fmnist_int8.onnx" 41 | 42 | ### Renaming Node 43 | - Rename the input node of the converted ti_model to 'input'. This will help in inference. 44 | 45 | ### Saving ONNX model 46 | - Overwrite the exported ti_model with this updated node name model and save model with same file name "fmnist_int8.onnx" -------------------------------------------------------------------------------- /tinyml-modeloptimization/torchmodelopt/examples/fmnist_image_classification/run_fmnist.py: -------------------------------------------------------------------------------- 1 | """ 2 | Run inference on a FMNIST ONNX model specified as the argument 3 | Contributed by Ajay Jayaraj (ajayj@ti.com) 4 | """ 5 | import argparse 6 | import sys 7 | import timeit 8 | 9 | import numpy as np 10 | import onnxruntime as ort 11 | 12 | 13 | def get_args(): 14 | parser = argparse.ArgumentParser(description="Run inference with FMNIST ONNX model") 15 | parser.add_argument("--model-name", type=str, required=True, help="ONNX model name") 16 | 17 | args = parser.parse_args() 18 | 19 | return args 20 | 21 | 22 | model_name = get_args().model_name 23 | 24 | classes = [ 25 | "T-shirt/top", 26 | "Trouser", 27 | "Pullover", 28 | "Dress", 29 | "Coat", 30 | "Sandal", 31 | "Shirt", 32 | "Sneaker", 33 | "Bag", 34 | "Ankle boot", 35 | ] 36 | 37 | INPUT_NAME = "input" 38 | 39 | 40 | # Use as decorator - @timethis 41 | def timethis(func): 42 | def timed(*args, **kwargs): 43 | start = timeit.default_timer() 44 | result = func(*args, **kwargs) 45 | end = timeit.default_timer() 46 | print('Function', func.__name__, 'time:', round((end - start) * 1000, 4), 'ms') 47 | return result 48 | 49 | return timed 50 | 51 | 52 | # 53 | # Load the image (Ankle boot) 54 | # 55 | flattened_input = np.fromfile('input.dat', dtype=np.float32) 56 | input_image = flattened_input.reshape((1, 28, 28)) 57 | 58 | # 59 | # Run inference using ONNX RT 60 | # 61 | 62 | # Set graph optimization level 63 | ort_session_options = ort.SessionOptions() 64 | ort_session_options.graph_optimization_level = ort.GraphOptimizationLevel.ORT_ENABLE_EXTENDED 65 | 66 | ort_sess = ort.InferenceSession(model_name, ort_session_options) 67 | 68 | 69 | @timethis 70 | def run_onnxrt(ort_session): 71 | prediction = ort_session.run(None, {INPUT_NAME: input_image}) 72 | return prediction 73 | 74 | 75 | outputs = run_onnxrt(ort_sess) 76 | 77 | # Outputs - 1x10 78 | conf_1 = outputs[0][0] 79 | print(conf_1) 80 | print(classes[conf_1.argmax(0)]) 81 | 82 | sys.exit(0) 83 | -------------------------------------------------------------------------------- /tinyml-modeloptimization/torchmodelopt/examples/motor_fault_time_series_classification/README.md: -------------------------------------------------------------------------------- 1 | # Motor Fault Time Series Classification 2 | 3 | Motor Fault Dataset is a subset of motor fault dataset prepared by TIs Internal Team. The dataset consists of vibrations received from running motors. The motors can be classified as Normal, Localized Fault, Erosion Fault, Flaking Fault. The dataset has 4800030 samples. Each sample has 4 variables and 1 target. 4 | 5 | This example will use a Deep Learning model to train and classify the type of motor fault. 6 | 7 | ## Walkthrough of this Example 8 | 1. Create train and test dataloader from csv 9 | 2. Configure the training and quantization params 10 | 4. Wrap the trained model around `TinyMLFxModule` 11 | 5. Train and test this ti_model for `QAT/PTQ` 12 | 6. Export the quantized model 13 | 14 | ## Let's understand each step 15 | 16 | ### Prepare Dataloader 17 | The MotorFault dataset is derived from a subset of an in-house dataset created by TI. It is structured by segmenting data into windows of data points. The data follows the NCHW format and is divided in a 4:1 ratio for training and testing dataloaders. The samples are shuffled within the dataloader. 18 | 19 | ### Configure Dataloader 20 | This example comes with various configuration of dataloader 21 | - **BATCH_SIZE** (N): Creates batches of windows 22 | - **HIDDEN_CHANNELS** (C): Provide the hidden channels for convolution layers 23 | - **WINDOW_LENGTH** (H): Decides the length of windows 24 | - **WINDOW_OFFSET**: Offset of datapoint for each window 25 | 26 | ### Using Quantization 27 | - **QUANTIZATION_METHOD**: QAT / PTQ 28 | - **WEIGHT_BITWIDTH**: Bit width of weights 29 | - **ACTIVATION_BITWIDTH**: Bit width of activations 30 | - **QUANTIZATION_DEVICE_TYPE**: Generic quantization or TI-NPU supported quantization 31 | - **NORMALIZE_INPUT**: Model normalizes the input or not 32 | 33 | ### Train and Test Quantization on CNN Model 34 | For lower bitwidth in quantization, the epochs of training or calibration is increased, whereas for high bitwidth the epochs are reduced. This is done due to the ease of learning for high bitwidth. The QAT training occurs in `train_model` and calibration for PTQ is done using `calibrate_model`. 35 | 36 | For the QAT training, the learning rate is lowered to avoid deviations from trained values. The model is tested on the test dataloader using the `validate_model` function 37 | 38 | ### Exporting the quantized model 39 | The model is first converted and then exported using the `export_model` function. The accuracy of exported model which is the end-user model is also checked using `validate_saved_model`. -------------------------------------------------------------------------------- /tinyml-modeloptimization/torchmodelopt/pyproject.toml: -------------------------------------------------------------------------------- 1 | [build-system] 2 | requires = ["setuptools>=42", "wheel"] 3 | build-backend = "setuptools.build_meta" 4 | 5 | [project] 6 | name = "tinyml_torchmodelopt" 7 | version = "1.0.0" 8 | description = "Tiny ML Model Optimization ToolKit For Torch" 9 | authors = [ 10 | { name = "Adithya Thonse", email = "thonse@ti.com" } 11 | ] 12 | license = { text = "BSD 3-Clause" } 13 | readme = "README.md" 14 | requires-python = "==3.10.*" 15 | classifiers = [ 16 | "Development Status :: 4 - Beta", 17 | "Programming Language :: Python :: 3.10" 18 | ] 19 | dependencies = [ 20 | "numpy==1.26.4", 21 | "Cython==3.0.11", 22 | "protobuf==5.27.3", 23 | "pillow>=10.4.0", 24 | "onnxsim==0.4.36", 25 | "onnx==1.16.1", 26 | "onnxsim==0.4.36", 27 | "onnxoptimizer==0.3.13", 28 | "onnxruntime==1.19.0", 29 | "progressbar==2.5", 30 | "protobuf==5.27.3", 31 | "rich==13.7.1", 32 | "pandas==2.2.2", 33 | "colorama==0.4.6", 34 | "torch==2.3.0", 35 | ] 36 | 37 | [project.urls] 38 | "Homepage" = "https://github.com/TexasInstruments/tinyml-tensorlab/tree/main/tinyml-modeloptimization" 39 | 40 | [tool.setuptools] 41 | include-package-data = true 42 | 43 | 44 | [tool.setuptools.packages.find] 45 | include = ["tinyml_torchmodelopt*"] 46 | exclude = ["tests*"] 47 | 48 | [tool.setuptools.dynamic] 49 | version = {attr = "tinyml_torchmodelopt.__version__"} 50 | -------------------------------------------------------------------------------- /tinyml-modeloptimization/torchmodelopt/requirements/requirements.txt: -------------------------------------------------------------------------------- 1 | numpy==1.26.4 2 | Cython==3.0.11 3 | protobuf==5.27.3 4 | pillow==10.4.0 5 | onnxsim==0.4.36 6 | onnx==1.16.1 7 | onnxsim==0.4.36 8 | onnxoptimizer==0.3.13 9 | onnxruntime==1.19.0 10 | progressbar==2.5 11 | protobuf==5.27.3 12 | rich==13.7.1 13 | pandas==2.2.2 14 | colorama==0.4.6 15 | torch==2.3.0 16 | -------------------------------------------------------------------------------- /tinyml-modeloptimization/torchmodelopt/setup.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Copyright (c) 2018-2023, Texas Instruments 4 | # All Rights Reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are met: 8 | # 9 | # * Redistributions of source code must retain the above copyright notice, this 10 | # list of conditions and the following disclaimer. 11 | # 12 | # * Redistributions in binary form must reproduce the above copyright notice, 13 | # this list of conditions and the following disclaimer in the documentation 14 | # and/or other materials provided with the distribution. 15 | # 16 | # * Neither the name of the copyright holder nor the names of its 17 | # contributors may be used to endorse or promote products derived from 18 | # this software without specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | ###################################################################### 32 | # Installing dependencies 33 | ################################################################################# 34 | # upgrade pip 35 | python -m ensurepip --upgrade 36 | python -m pip install --no-input --upgrade pip setuptools 37 | 38 | echo 'Installing python packages...' 39 | python -m pip install --no-input -r requirements/requirements.txt 40 | #python -m pip install --no-input -r requirements/requirements_ti_packages.txt 41 | 42 | #echo 'installing pytorch...' 43 | #python -m pip install --no-input torch 44 | echo 'installing the pytorch model optimization toolkit...' 45 | python -m pip install --editable . --use-pep517 46 | -------------------------------------------------------------------------------- /tinyml-modeloptimization/torchmodelopt/tinyml_torchmodelopt/__init__.py: -------------------------------------------------------------------------------- 1 | ################################################################################# 2 | # Copyright (c) 2018-2023, Texas Instruments Incorporated - http://www.ti.com 3 | # All Rights Reserved. 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions are met: 7 | # 8 | # * Redistributions of source code must retain the above copyright notice, this 9 | # list of conditions and the following disclaimer. 10 | # 11 | # * Redistributions in binary form must reproduce the above copyright notice, 12 | # this list of conditions and the following disclaimer in the documentation 13 | # and/or other materials provided with the distribution. 14 | # 15 | # * Neither the name of the copyright holder nor the names of its 16 | # contributors may be used to endorse or promote products derived from 17 | # this software without specific prior written permission. 18 | # 19 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 20 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 23 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 26 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 27 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | # 30 | ################################################################################# 31 | 32 | 33 | -------------------------------------------------------------------------------- /tinyml-modeloptimization/torchmodelopt/tinyml_torchmodelopt/quantization/__init__.py: -------------------------------------------------------------------------------- 1 | ################################################################################# 2 | # Copyright (c) 2018-2023, Texas Instruments Incorporated - http://www.ti.com 3 | # All Rights Reserved. 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions are met: 7 | # 8 | # * Redistributions of source code must retain the above copyright notice, this 9 | # list of conditions and the following disclaimer. 10 | # 11 | # * Redistributions in binary form must reproduce the above copyright notice, 12 | # this list of conditions and the following disclaimer in the documentation 13 | # and/or other materials provided with the distribution. 14 | # 15 | # * Neither the name of the copyright holder nor the names of its 16 | # contributors may be used to endorse or promote products derived from 17 | # this software without specific prior written permission. 18 | # 19 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 20 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 23 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 26 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 27 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | # 30 | ################################################################################# 31 | 32 | from . import base, generic, tinpu 33 | from .common import * 34 | from .base.fx import TinyMLQuantFxBaseModule 35 | from .generic import GenericTinyMLQATFxModule, GenericTinyMLPTQFxModule 36 | from .tinpu import TINPUTinyMLQATFxModule, TINPUTinyMLPTQFxModule 37 | -------------------------------------------------------------------------------- /tinyml-modeloptimization/torchmodelopt/tinyml_torchmodelopt/quantization/base/fx/__init__.py: -------------------------------------------------------------------------------- 1 | ################################################################################# 2 | # Copyright (c) 2018-2023, Texas Instruments Incorporated - http://www.ti.com 3 | # All Rights Reserved. 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions are met: 7 | # 8 | # * Redistributions of source code must retain the above copyright notice, this 9 | # list of conditions and the following disclaimer. 10 | # 11 | # * Redistributions in binary form must reproduce the above copyright notice, 12 | # this list of conditions and the following disclaimer in the documentation 13 | # and/or other materials provided with the distribution. 14 | # 15 | # * Neither the name of the copyright holder nor the names of its 16 | # contributors may be used to endorse or promote products derived from 17 | # this software without specific prior written permission. 18 | # 19 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 20 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 23 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 26 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 27 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | # 30 | ################################################################################# 31 | 32 | from .quant_utils import * 33 | from .qconfig_types import * 34 | from .quant_base import * 35 | -------------------------------------------------------------------------------- /tinyml-modeloptimization/torchmodelopt/tinyml_torchmodelopt/quantization/base/fx/functional_utils.py: -------------------------------------------------------------------------------- 1 | ################################################################################# 2 | # Copyright (c) 2018-2023, Texas Instruments Incorporated - http://www.ti.com 3 | # All Rights Reserved. 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions are met: 7 | # 8 | # * Redistributions of source code must retain the above copyright notice, this 9 | # list of conditions and the following disclaimer. 10 | # 11 | # * Redistributions in binary form must reproduce the above copyright notice, 12 | # this list of conditions and the following disclaimer in the documentation 13 | # and/or other materials provided with the distribution. 14 | # 15 | # * Neither the name of the copyright holder nor the names of its 16 | # contributors may be used to endorse or promote products derived from 17 | # this software without specific prior written permission. 18 | # 19 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 20 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 23 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 26 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 27 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | # 30 | ################################################################################# 31 | 32 | import torch 33 | 34 | 35 | def _ceil2_func(x): 36 | y = torch.pow(2,torch.ceil(torch.log2(x))) 37 | return y 38 | 39 | def _ceil2_tensor(x): 40 | y = x 41 | if x.data.abs().sum() != 0: 42 | x2 = _ceil2_func(torch.abs(x)) 43 | y = torch.sign(x) * x2 44 | return y 45 | 46 | def _round_tensor(x): 47 | y = torch.round(x) 48 | return y 49 | 50 | def _propagate_quant_ste(x, y): 51 | # straight-through estimation (STE) - this is the preferred mode for propagating outputs for quantization 52 | # the backward gradients uses x (i.e. the input itself) and not y (the output) 53 | # because the effect of y is completely detached during forward 54 | # this works functionally as STE, but exports an onnx graph containing 55 | # all the operators used to compute y as well 56 | # out = x + (y - x).detach() 57 | # 58 | # this is another way of doing STE. in this case the operators used to generate y are skipped from onnx graph 59 | out = x.clone() 60 | out.data = y.data 61 | return out 62 | 63 | def ceil2_tensor(x): 64 | y = _ceil2_tensor(x) 65 | return _propagate_quant_ste(x, y) 66 | 67 | def round_tensor(x): 68 | y = _round_tensor(x) 69 | return _propagate_quant_ste(x, y) 70 | 71 | def _adjust_qparams_power2_scale(symmetric, min_val, max_val, quant_min, quant_max, scale, zero_point, eps): 72 | r"""Calculates the quantization parameters.""" 73 | # make scale a power of 2 value 74 | scale = ceil2_tensor(scale) 75 | scale = torch.max(scale, eps) 76 | if not symmetric: 77 | # adjust the zero_point based on new scale 78 | min_val_neg = torch.min(min_val, torch.zeros_like(min_val)) 79 | zero_point = quant_min - torch.round(min_val_neg / scale).to(torch.int) 80 | zero_point = torch.clamp(zero_point, quant_min, quant_max) 81 | return scale, zero_point -------------------------------------------------------------------------------- /tinyml-modeloptimization/torchmodelopt/tinyml_torchmodelopt/quantization/base/fx/quant_utils.py: -------------------------------------------------------------------------------- 1 | ################################################################################# 2 | # Copyright (c) 2018-2023, Texas Instruments Incorporated - http://www.ti.com 3 | # All Rights Reserved. 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions are met: 7 | # 8 | # * Redistributions of source code must retain the above copyright notice, this 9 | # list of conditions and the following disclaimer. 10 | # 11 | # * Redistributions in binary form must reproduce the above copyright notice, 12 | # this list of conditions and the following disclaimer in the documentation 13 | # and/or other materials provided with the distribution. 14 | # 15 | # * Neither the name of the copyright holder nor the names of its 16 | # contributors may be used to endorse or promote products derived from 17 | # this software without specific prior written permission. 18 | # 19 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 20 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 23 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 26 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 27 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | # 30 | ################################################################################# 31 | 32 | 33 | import copy 34 | from colorama import Fore 35 | 36 | 37 | ################################################################################## 38 | def add_color(string, color=None): 39 | if color: 40 | string = '{}{}{}'.format(color, string, Fore.RESET) 41 | # 42 | return string 43 | # 44 | 45 | def print_color(string, *args, **kwargs): 46 | if 'color' in kwargs: 47 | string = add_color(string, kwargs['color']) 48 | kwargs_copy = copy.deepcopy(kwargs) 49 | del kwargs_copy['color'] 50 | else: 51 | kwargs_copy = kwargs 52 | # 53 | print(string, *args, **kwargs_copy) 54 | # 55 | 56 | 57 | print_once_dict = {} 58 | def print_once(string, *args, **kwargs): 59 | global print_once_dict 60 | if string not in list(print_once_dict.keys()): 61 | print_color(string, *args, **kwargs) 62 | print_once_dict[string] = True 63 | # 64 | return 65 | 66 | 67 | ################################################################################## 68 | 69 | 70 | -------------------------------------------------------------------------------- /tinyml-modeloptimization/torchmodelopt/tinyml_torchmodelopt/quantization/tinpu/__init__.py: -------------------------------------------------------------------------------- 1 | ################################################################################# 2 | # Copyright (c) 2018-2023, Texas Instruments Incorporated - http://www.ti.com 3 | # All Rights Reserved. 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions are met: 7 | # 8 | # * Redistributions of source code must retain the above copyright notice, this 9 | # list of conditions and the following disclaimer. 10 | # 11 | # * Redistributions in binary form must reproduce the above copyright notice, 12 | # this list of conditions and the following disclaimer in the documentation 13 | # and/or other materials provided with the distribution. 14 | # 15 | # * Neither the name of the copyright holder nor the names of its 16 | # contributors may be used to endorse or promote products derived from 17 | # this software without specific prior written permission. 18 | # 19 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 20 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 23 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 26 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 27 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | # 30 | ################################################################################# 31 | 32 | from .quant_fx import TINPUTinyMLQATFxModule, TINPUTinyMLPTQFxModule 33 | -------------------------------------------------------------------------------- /tinyml-modeloptimization/torchmodelopt/tinyml_torchmodelopt/surgery/README.md: -------------------------------------------------------------------------------- 1 | ## Easy to use model surgery utilities using torch.fx 2 | 3 | This can be used to replace modules in a model that are derived from torch.nn.Modules. Most of the common classes used a model such as torch.nn.Conv2d, torch.nn.BatchNorm2d, torch.nn.ReLU are derived from torch.nn.Modules, so they can be easily replaced. If a model has used torch.relu operator directory or a x.relu (x being a tensor), those can also be replaced by this surgery utility. 4 | ## APIs 5 | 6 | ### convert_to_lite_fx 7 | This is the main model surgery function. 8 | #### Usage: 9 | ``` 10 | ## insert this line into your model training script 11 | model = convert_to_lite_fx(model) 12 | ### get_replacement_dict_default 13 | This can be used to get the default replacement dict. This replacement dict can then be modified and passed to the convert api. 14 | 15 | #### Usage: 16 | ``` 17 | replacement_dict = copy.deepcopy(edgeai_torchmodelopt.xmodelopt.surgery.v2.get_replacement_dict_default()) 18 | replacement_dict.update({torch.nn.GELU: torch.nn.ReLU}) 19 | ``` 20 | 21 | Now apply the conversion using the updated replacement_dict 22 | ``` 23 | model = convert_to_lite_fx(model, replacement_dict=replacement_dict) 24 | ``` 25 | 26 | The value of the replacement entry can also be a function name: 27 | ``` 28 | replacement_dict = get_replacement_dict_default() 29 | replacement_dict.update({'my_layer':my_replacement_function}) 30 | ``` 31 | -------------------------------------------------------------------------------- /tinyml-modeloptimization/torchmodelopt/tinyml_torchmodelopt/surgery/custom_modules.py: -------------------------------------------------------------------------------- 1 | ################################################################################# 2 | # Copyright (c) 2018-2023, Texas Instruments Incorporated - http://www.ti.com 3 | # All Rights Reserved. 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions are met: 7 | # 8 | # * Redistributions of source code must retain the above copyright notice, this 9 | # list of conditions and the following disclaimer. 10 | # 11 | # * Redistributions in binary form must reproduce the above copyright notice, 12 | # this list of conditions and the following disclaimer in the documentation 13 | # and/or other materials provided with the distribution. 14 | # 15 | # * Neither the name of the copyright holder nor the names of its 16 | # contributors may be used to endorse or promote products derived from 17 | # this software without specific prior written permission. 18 | # 19 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 20 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 23 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 26 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 27 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | # 30 | ################################################################################# 31 | 32 | import torch 33 | 34 | # Wrapper module for modules in nn package 35 | class InstaModule(torch.nn.Module): 36 | def __init__(self, preDefinedLayer: torch.nn.Module) -> None: 37 | super().__init__() 38 | self.model = preDefinedLayer 39 | 40 | def forward(self, x): 41 | return self.model(x) 42 | -------------------------------------------------------------------------------- /tinyml-modeloptimization/torchmodelopt/tinyml_torchmodelopt/surgery/custom_surgery_functions.py: -------------------------------------------------------------------------------- 1 | ################################################################################# 2 | # Copyright (c) 2018-2023, Texas Instruments Incorporated - http://www.ti.com 3 | # All Rights Reserved. 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions are met: 7 | # 8 | # * Redistributions of source code must retain the above copyright notice, this 9 | # list of conditions and the following disclaimer. 10 | # 11 | # * Redistributions in binary form must reproduce the above copyright notice, 12 | # this list of conditions and the following disclaimer in the documentation 13 | # and/or other materials provided with the distribution. 14 | # 15 | # * Neither the name of the copyright holder nor the names of its 16 | # contributors may be used to endorse or promote products derived from 17 | # this software without specific prior written permission. 18 | # 19 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 20 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 23 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 26 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 27 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | # 30 | ################################################################################# 31 | 32 | import torch 33 | from torch.fx import symbolic_trace 34 | 35 | from . import replacer 36 | 37 | 38 | def remove_identity(model: torch.nn.Module, verbose_mode=False, **kwargs): 39 | # removed due to RuntimeError 40 | # RuntimeError: Only Tensors created explicitly by the user (graph leaves) support the deepcopy protocol at the moment. 41 | # model=deepcopy(model) 42 | 43 | traced_model = symbolic_trace(model) if not isinstance(model, torch.fx.GraphModule) else model 44 | modules = dict(traced_model.named_modules()) 45 | n = 0 46 | nodes = [] 47 | for node in traced_model.graph.nodes: 48 | if (node.op == 'call_module') and isinstance(modules[node.target], torch.nn.Identity): 49 | nodes.append(node) 50 | for node in nodes: 51 | try: 52 | node.replace_all_uses_with(node.args[0]) 53 | copy_found = False 54 | for node_1 in nodes: 55 | if node != node_1 and node.target == node_1.target: 56 | copy_found = True 57 | break 58 | if not copy_found: 59 | parent_name, name = replacer._get_parent_name(node.target) 60 | modules[parent_name].__delattr__(name) 61 | modules.pop(node.target) 62 | traced_model.graph.erase_node(node) 63 | n += 1 64 | except Exception as e: 65 | if verbose_mode: 66 | print(n, e) 67 | traced_model.graph.lint() 68 | traced_model.recompile() 69 | if verbose_mode: 70 | print('Identity removed', n) 71 | return traced_model 72 | -------------------------------------------------------------------------------- /tinyml-modeloptimization/torchmodelopt/version.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2018-2023, Texas Instruments 2 | # All Rights Reserved. 3 | # 4 | # Redistribution and use in source and binary forms, with or without 5 | # modification, are permitted provided that the following conditions are met: 6 | # 7 | # * Redistributions of source code must retain the above copyright notice, this 8 | # list of conditions and the following disclaimer. 9 | # 10 | # * Redistributions in binary form must reproduce the above copyright notice, 11 | # this list of conditions and the following disclaimer in the documentation 12 | # and/or other materials provided with the distribution. 13 | # 14 | # * Neither the name of the copyright holder nor the names of its 15 | # contributors may be used to endorse or promote products derived from 16 | # this software without specific prior written permission. 17 | # 18 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 22 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 25 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | import argparse 30 | 31 | __version__ = '1.0.0' 32 | 33 | 34 | def print_version(): 35 | print(__version__) 36 | 37 | 38 | def print_version_(delimiter): 39 | version_str = delimiter.join([f'{r:0>2}' for r in __version__.split('.')]) 40 | print(version_str) 41 | 42 | 43 | if __name__ == '__main__': 44 | parser = argparse.ArgumentParser() 45 | parser.add_argument('--delimiter', default=None) 46 | args = parser.parse_args() 47 | if args.delimiter is not None: 48 | print_version_(args.delimiter) 49 | else: 50 | print_version() 51 | 52 | -------------------------------------------------------------------------------- /tinyml-modelzoo/graphs/cycles_vs_memory_usage_plots/arcFault_c28_total_memory_vs_cycles.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TexasInstruments/tinyml-tensorlab/3a2d9e8eefdb3ee560d42aa8c01e31eeaf79f166/tinyml-modelzoo/graphs/cycles_vs_memory_usage_plots/arcFault_c28_total_memory_vs_cycles.png -------------------------------------------------------------------------------- /tinyml-modelzoo/graphs/cycles_vs_memory_usage_plots/generic_c28_total_memory_vs_cycles.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TexasInstruments/tinyml-tensorlab/3a2d9e8eefdb3ee560d42aa8c01e31eeaf79f166/tinyml-modelzoo/graphs/cycles_vs_memory_usage_plots/generic_c28_total_memory_vs_cycles.png -------------------------------------------------------------------------------- /tinyml-modelzoo/graphs/cycles_vs_memory_usage_plots/motorfault_c28_total_memory_vs_cycles.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TexasInstruments/tinyml-tensorlab/3a2d9e8eefdb3ee560d42aa8c01e31eeaf79f166/tinyml-modelzoo/graphs/cycles_vs_memory_usage_plots/motorfault_c28_total_memory_vs_cycles.png -------------------------------------------------------------------------------- /tinyml-modelzoo/graphs/model_vs_accuracy_plots/MotorFault_128Input_RAW_128Feature_1Frame_3InputChannel_removeDC_2D1_accuracy_comparison.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TexasInstruments/tinyml-tensorlab/3a2d9e8eefdb3ee560d42aa8c01e31eeaf79f166/tinyml-modelzoo/graphs/model_vs_accuracy_plots/MotorFault_128Input_RAW_128Feature_1Frame_3InputChannel_removeDC_2D1_accuracy_comparison.png -------------------------------------------------------------------------------- /tinyml-modelzoo/graphs/model_vs_accuracy_plots/MotorFault_256Input_FFTBIN_16Feature_8Frame_3InputChannel_removeDC_1D_accuracy_comparison.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TexasInstruments/tinyml-tensorlab/3a2d9e8eefdb3ee560d42aa8c01e31eeaf79f166/tinyml-modelzoo/graphs/model_vs_accuracy_plots/MotorFault_256Input_FFTBIN_16Feature_8Frame_3InputChannel_removeDC_1D_accuracy_comparison.png -------------------------------------------------------------------------------- /tinyml-modelzoo/graphs/model_vs_accuracy_plots/MotorFault_256Input_FFTBIN_16Feature_8Frame_3InputChannel_removeDC_2D1_accuracy_comparison.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TexasInstruments/tinyml-tensorlab/3a2d9e8eefdb3ee560d42aa8c01e31eeaf79f166/tinyml-modelzoo/graphs/model_vs_accuracy_plots/MotorFault_256Input_FFTBIN_16Feature_8Frame_3InputChannel_removeDC_2D1_accuracy_comparison.png -------------------------------------------------------------------------------- /tinyml-modelzoo/graphs/model_vs_accuracy_plots/MotorFault_256Input_FFT_128Feature_1Frame_3InputChannel_removeDC_2D1_accuracy_comparison.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TexasInstruments/tinyml-tensorlab/3a2d9e8eefdb3ee560d42aa8c01e31eeaf79f166/tinyml-modelzoo/graphs/model_vs_accuracy_plots/MotorFault_256Input_FFT_128Feature_1Frame_3InputChannel_removeDC_2D1_accuracy_comparison.png -------------------------------------------------------------------------------- /tinyml-tinyverse/.gitignore: -------------------------------------------------------------------------------- 1 | /.pkl_memoize_py3/ 2 | build/ 3 | dist/ 4 | torchvision.egg-info/ 5 | torchvision/version.py 6 | */**/__pycache__ 7 | */__pycache__ 8 | */*.pyc 9 | */**/*.pyc 10 | */**/**/*.pyc 11 | */**/*~ 12 | *~ 13 | data/ 14 | *.egg-info/ 15 | 16 | docs/build 17 | # sphinx-gallery 18 | docs/source/auto_examples/ 19 | docs/source/gen_modules/ 20 | docs/source/generated/ 21 | docs/source/models/generated/ 22 | # pytorch-sphinx-theme gets installed here 23 | docs/src 24 | 25 | .coverage 26 | htmlcov 27 | .*.swp 28 | *.so* 29 | *.dylib* 30 | */*.so* 31 | */*.dylib* 32 | *.swp 33 | *.swo 34 | gen.yml 35 | .mypy_cache 36 | .vscode/ 37 | .idea/ 38 | *.orig 39 | *-checkpoint.ipynb 40 | *.venv 41 | 42 | ## Xcode User settings 43 | xcuserdata/ 44 | 45 | # direnv 46 | .direnv 47 | .envrc 48 | 49 | data/ 50 | !data/datasets/readme.txt 51 | !data/checkpoints/readme.txt 52 | !data/downloads/readme.txt -------------------------------------------------------------------------------- /tinyml-tinyverse/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2023-2024, Texas Instruments Incorporated 2 | All Rights Reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | * Neither the name of the copyright holder nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 25 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | ---------------------------------------------------------------------- 30 | Few lines are from: https://github.com/pytorch/vision 31 | 32 | BSD 3-Clause License 33 | 34 | Copyright (c) Soumith Chintala 2016, 35 | All rights reserved. 36 | 37 | Redistribution and use in source and binary forms, with or without 38 | modification, are permitted provided that the following conditions are met: 39 | 40 | * Redistributions of source code must retain the above copyright notice, this 41 | list of conditions and the following disclaimer. 42 | 43 | * Redistributions in binary form must reproduce the above copyright notice, 44 | this list of conditions and the following disclaimer in the documentation 45 | and/or other materials provided with the distribution. 46 | 47 | * Neither the name of the copyright holder nor the names of its 48 | contributors may be used to endorse or promote products derived from 49 | this software without specific prior written permission. 50 | 51 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 52 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 53 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 54 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 55 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 56 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 57 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 58 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 59 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 60 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /tinyml-tinyverse/README.md: -------------------------------------------------------------------------------- 1 | # Tiny ML TinyVerse 2 | 3 | - This repository is a collection of all the base level scripts that are meant to be stitched together and run by the Tiny ML-Modelmaker 4 | - Although the scripts itself can run standalone, it is not recommended to play with it unless you're a developer who understands what is going in here. 5 | 6 | -------------------------------------------------------------------------------- /tinyml-tinyverse/pyproject.toml: -------------------------------------------------------------------------------- 1 | [build-system] 2 | requires = ["setuptools>=42", "wheel"] 3 | build-backend = "setuptools.build_meta" 4 | 5 | [project] 6 | name = "tinyml_tinyverse" 7 | version = "1.0.0" 8 | description = "A tiny machine learning project in the tinyverse" 9 | authors = [ 10 | { name = "Adithya Thonse", email = "thonse@ti.com" } 11 | ] 12 | license = { text = "BSD 3-Clause" } 13 | readme = "README.md" 14 | requires-python = "==3.10.*" 15 | classifiers = [ 16 | "Development Status :: 4 - Beta", 17 | "Programming Language :: Python :: 3.10" 18 | ] 19 | keywords = ["artificial intelligence", "deep learning", "image classification", "visual wake words", "time series classification", "audio classification", "keyword spotting"] 20 | 21 | dependencies = [ 22 | "numpy==1.26.4", 23 | "onnx==1.16.1", 24 | "onnxruntime==1.19.0", 25 | "protobuf==5.27.3", 26 | "pandas==2.2.2", 27 | "pathlib2==2.3.7.post1", 28 | "PyYAML==6.0.2", 29 | "scipy==1.13.1", 30 | "tabulate==0.9.0", 31 | "torcheval==0.0.7", 32 | "torchinfo==1.8.0", 33 | "cryptography==43.0.1", 34 | "matplotlib==3.9.2", 35 | "scikit-learn==1.5.2", 36 | "torch==2.3.0", 37 | "cython", 38 | "pycocotools", 39 | "opencv-python", 40 | "pillow", 41 | # "tinyml_torchmodelopt @ git+ssh://git@bitbucket.itg.ti.com/tinyml-algo/tinyml-modeloptimization.git@main#subdirectory=torchmodelopt", 42 | "tinyml_torchmodelopt @ git+https://github.com/TexasInstruments/tinyml-tensorlab.git@main#subdirectory=tinyml-modeloptimization/torchmodelopt", 43 | "ti_mcu_nnc @ https://software-dl.ti.com/mctools/esd/tvm/mcu/ti_mcu_nnc-1.3.0-cp310-cp310-linux_x86_64.whl ; platform_system == 'Linux'", 44 | "ti_mcu_nnc @ https://software-dl.ti.com/mctools/esd/tvm/mcu/ti_mcu_nnc-1.3.0-cp310-cp310-win_amd64.whl ; platform_system == 'Windows'", 45 | "colorama==0.4.6" 46 | ] 47 | 48 | [project.urls] 49 | Homepage = "https://github.com/TexasInstruments/tinyml-tensorlab/tree/main/tinyml-tinyverse" 50 | "Bug Reports" = "https://e2e.ti.com/support/processors/" 51 | 52 | [tool.setuptools] 53 | include-package-data = true 54 | 55 | [tool.setuptools.packages.find] 56 | include = ["tinyml_tinyverse*"] 57 | exclude = ["tests*"] 58 | -------------------------------------------------------------------------------- /tinyml-tinyverse/requirements/requirements.txt: -------------------------------------------------------------------------------- 1 | numpy==1.26.4 2 | onnx==1.16.1 3 | onnxruntime==1.19.0 4 | protobuf==5.27.3 5 | pandas==2.2.2 6 | pathlib2==2.3.7.post1 7 | PyYAML==6.0.2 8 | scipy==1.13.1 9 | tabulate==0.9.0 10 | torcheval==0.0.7 11 | torchinfo==1.8.0 12 | cryptography==43.0.1 13 | matplotlib==3.9.2 14 | scikit-learn==1.5.2 15 | pywavelets==1.8.0 16 | colorama==0.4.6 17 | -------------------------------------------------------------------------------- /tinyml-tinyverse/requirements/requirements_ti_packages.txt: -------------------------------------------------------------------------------- 1 | https://software-dl.ti.com/mctools/esd/tvm/mcu/ti_mcu_nnc-1.3.0-cp310-cp310-linux_x86_64.whl 2 | # https://software-dl.ti.com/mctools/esd/tvm/mcu/ti_mcu_nnc-1.3.0-cp310-cp310-win_amd64.whl # --> Use this for Windows 3 | -------------------------------------------------------------------------------- /tinyml-tinyverse/setup.py: -------------------------------------------------------------------------------- 1 | from setuptools import setup 2 | 3 | if __name__ == '__main__': 4 | setup() 5 | # import os 6 | # import subprocess 7 | # 8 | # from setuptools import find_packages, setup 9 | # 10 | # 11 | # def git_hash(): 12 | # git_path = '.' if os.path.exists('.git') else ('..' if os.path.exists(os.path.join('..', '.git')) else None) 13 | # if git_path: 14 | # hash = subprocess.check_output(['git', 'rev-parse', 'HEAD']).strip() 15 | # return hash[:7] if (hash is not None) else None 16 | # else: 17 | # return None 18 | # 19 | # 20 | # def get_version(): 21 | # # from version import __version__ 22 | # __version__ = '0.9.0' 23 | # hash = git_hash() 24 | # version_str = __version__ + '+' + hash.strip().decode('ascii') if (hash is not None) else __version__ 25 | # return version_str 26 | # 27 | # 28 | # if __name__ == '__main__': 29 | # version_str = get_version() 30 | # 31 | # long_description = '' 32 | # with open('README.md', encoding="utf8") as readme: 33 | # long_description = readme.read() 34 | # 35 | # setup( 36 | # name='tinyml_tinyverse', 37 | # version=get_version(), 38 | # description='Tiny ML TinyVerse', 39 | # long_description=long_description, 40 | # long_description_content_type='text/markdown', 41 | # url='https://github.com/TexasInstruments/tinyml-tensorlab/tree/main/tinyml-tinyverse', 42 | # author='Adithya Thonse', 43 | # author_email='thonse@ti.com', 44 | # classifiers=[ 45 | # 'Development Status :: 1 - Beta' 46 | # 'Programming Language :: Python :: 3.10' 47 | # ], 48 | # keywords = 'artifical intelligence, deep learning, image classification, visual wake words, time series classsification, audio_classification keyword spotting', 49 | # python_requires='>=3.10', 50 | # packages=find_packages(), 51 | # include_package_data=True, 52 | # install_requires=[], 53 | # project_urls={ 54 | # 'Source': 'https://github.com/TexasInstruments/tinyml-tensorlab/tree/main/tinyml-tinyverse', 55 | # 'Bug Reports': 'https://e2e.ti.com/support/processors/', 56 | # }, 57 | # ) 58 | -------------------------------------------------------------------------------- /tinyml-tinyverse/setup.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # system packages 4 | sudo apt-get install -y libjpeg-dev zlib1g-dev cmake libffi-dev protobuf-compiler 5 | 6 | ###################################################################### 7 | # upgrade pip 8 | python -m ensurepip --upgrade 9 | python -m pip install --no-input --upgrade pip setuptools 10 | ###################################################################### 11 | echo "installing pytorch - use the appropriate index-url from https://pytorch.org/get-started/locally/" 12 | python -m pip install --no-input torch==2.3.0 --index-url https://download.pytorch.org/whl/cu124 13 | 14 | echo 'Installing python packages...' 15 | python -m pip install --no-input cython wheel numpy==1.26.4 16 | python -m pip install --no-input torchinfo==1.8.0 pycocotools opencv-python 17 | python -m pip uninstall --yes pillow 18 | #python -m pip uninstall --no-input pillow-simd 19 | 20 | echo "installing requirements" 21 | python -m pip install --no-input -r requirements/requirements.txt 22 | python -m pip install --no-input -r requirements/requirements_ti_packages.txt 23 | 24 | ###################################################################### 25 | # can we move this inside the requirements file is used. 26 | #python -m pip install --no-input protobuf onnx==1.13.0 27 | 28 | ###################################################################### 29 | python -m pip install --editable . --use-pep517 30 | 31 | ###################################################################### 32 | # setup the edgeai_xvision package, which is inside references/edgeailite 33 | #python -m pip install --no-input -r ./references/edgeailite/requirements.txt 34 | #python -m pip install -e ./references/edgeailite/ 35 | 36 | -------------------------------------------------------------------------------- /tinyml-tinyverse/setup_cpu.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # system packages 4 | sudo apt-get install -y libjpeg-dev zlib1g-dev cmake libffi-dev protobuf-compiler 5 | 6 | ###################################################################### 7 | # upgrade pip 8 | python -m ensurepip --upgrade 9 | python -m pip install --no-input --upgrade pip setuptools 10 | ###################################################################### 11 | echo "installing pytorch - use the appropriate index-url from https://pytorch.org/get-started/locally/" 12 | python -m pip install --no-input torch==2.3.0 --index-url https://download.pytorch.org/whl/cpu 13 | 14 | echo 'Installing python packages...' 15 | python -m pip install --no-input cython wheel numpy==1.26.4 16 | python -m pip install --no-input torchinfo==1.8.0 pycocotools opencv-python 17 | pip uninstall --yes pillow 18 | #pip uninstall --no-input pillow-simd 19 | 20 | echo "installing requirements" 21 | python -m pip install --no-input -r requirements/requirements.txt 22 | python -m pip install --no-input -r requirements/requirements_ti_packages.txt 23 | ###################################################################### 24 | python -m pip install --editable . --use-pep517 25 | 26 | 27 | -------------------------------------------------------------------------------- /tinyml-tinyverse/tinyml_tinyverse/__init__.py: -------------------------------------------------------------------------------- 1 | ################################################################################# 2 | # Copyright (c) 2023-2024, Texas Instruments 3 | # All Rights Reserved. 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions are met: 7 | # 8 | # * Redistributions of source code must retain the above copyright notice, this 9 | # list of conditions and the following disclaimer. 10 | # 11 | # * Redistributions in binary form must reproduce the above copyright notice, 12 | # this list of conditions and the following disclaimer in the documentation 13 | # and/or other materials provided with the distribution. 14 | # 15 | # * Neither the name of the copyright holder nor the names of its 16 | # contributors may be used to endorse or promote products derived from 17 | # this software without specific prior written permission. 18 | # 19 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 20 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 23 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 26 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 27 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | ################################################################################# 30 | 31 | import sys 32 | 33 | 34 | # from . import audio_classification 35 | # from . import sensory 36 | # from . import vision 37 | 38 | 39 | def get_target_module(backend_name): 40 | this_module = sys.modules[__name__] 41 | target_module = getattr(this_module, backend_name) 42 | return target_module 43 | -------------------------------------------------------------------------------- /tinyml-tinyverse/tinyml_tinyverse/common/__init__.py: -------------------------------------------------------------------------------- 1 | ################################################################################# 2 | # Copyright (c) 2023-2024, Texas Instruments 3 | # All Rights Reserved. 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions are met: 7 | # 8 | # * Redistributions of source code must retain the above copyright notice, this 9 | # list of conditions and the following disclaimer. 10 | # 11 | # * Redistributions in binary form must reproduce the above copyright notice, 12 | # this list of conditions and the following disclaimer in the documentation 13 | # and/or other materials provided with the distribution. 14 | # 15 | # * Neither the name of the copyright holder nor the names of its 16 | # contributors may be used to endorse or promote products derived from 17 | # this software without specific prior written permission. 18 | # 19 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 20 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 23 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 26 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 27 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | ################################################################################# 30 | 31 | -------------------------------------------------------------------------------- /tinyml-tinyverse/tinyml_tinyverse/common/augmenters/__init__.py: -------------------------------------------------------------------------------- 1 | # One or more of these individual augmenters were picked from https://github.com/arundo/tsaug 2 | # usage of the repo is present at: https://tsaug.readthedocs.io/en/stable/notebook/Examples%20of%20augmenters.html 3 | # tsaug is licensed under the Apache License 2.0. See the LICENSE file in the same directory for details. 4 | # Tiny ML Tinyverse aims to improve upon this by adding custom Augmenters 5 | _default_seed = None 6 | from .add_noise import AddNoise 7 | from .convolve import Convolve 8 | from .crop import Crop 9 | from .drift import Drift 10 | from .dropout import Dropout 11 | # from .linear_transform import LinearTransform 12 | from .pool import Pool 13 | from .quantize import Quantize 14 | from .resize import Resize 15 | from .reverse import Reverse 16 | from .time_warp import TimeWarp 17 | -------------------------------------------------------------------------------- /tinyml-tinyverse/tinyml_tinyverse/common/augmenters/linear_transform.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TexasInstruments/tinyml-tensorlab/3a2d9e8eefdb3ee560d42aa8c01e31eeaf79f166/tinyml-tinyverse/tinyml_tinyverse/common/augmenters/linear_transform.py -------------------------------------------------------------------------------- /tinyml-tinyverse/tinyml_tinyverse/common/augmenters/reverse.py: -------------------------------------------------------------------------------- 1 | from typing import Optional, Tuple 2 | 3 | import numpy as np 4 | 5 | from .base import _Augmenter, _default_seed 6 | 7 | 8 | class Reverse(_Augmenter): 9 | """ 10 | Reverse the time line of series. 11 | 12 | Parameters 13 | ---------- 14 | repeats : int, optional 15 | The number of times a series is augmented. If greater than one, a series 16 | will be augmented so many times independently. This parameter can also 17 | be set by operator `*`. Default: 1. 18 | 19 | prob : float, optional 20 | The probability of a series is augmented. It must be in (0.0, 1.0]. This 21 | parameter can also be set by operator `@`. Default: 1.0. 22 | 23 | seed : int, optional 24 | The random seed. Default: None. 25 | 26 | """ 27 | 28 | def __init__( 29 | self, 30 | repeats: int = 1, 31 | prob: float = 1.0, 32 | seed: Optional[int] = _default_seed, 33 | ): 34 | super().__init__(repeats=repeats, prob=prob, seed=seed) 35 | 36 | @classmethod 37 | def _get_param_name(cls) -> Tuple[str, ...]: 38 | return tuple() 39 | 40 | def _augment_core( 41 | self, X: np.ndarray, Y: Optional[np.ndarray] 42 | ) -> Tuple[np.ndarray, Optional[np.ndarray]]: 43 | X_aug = X[:, ::-1, :].copy() # type: np.ndarray 44 | 45 | if Y is None: 46 | Y_aug = None # type: Optional[np.ndarray] 47 | else: 48 | Y_aug = Y[:, ::-1, :].copy() 49 | 50 | return X_aug, Y_aug 51 | -------------------------------------------------------------------------------- /tinyml-tinyverse/tinyml_tinyverse/common/compilation/__init__.py: -------------------------------------------------------------------------------- 1 | ################################################################################# 2 | # Copyright (c) 2023-2024, Texas Instruments 3 | # All Rights Reserved. 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions are met: 7 | # 8 | # * Redistributions of source code must retain the above copyright notice, this 9 | # list of conditions and the following disclaimer. 10 | # 11 | # * Redistributions in binary form must reproduce the above copyright notice, 12 | # this list of conditions and the following disclaimer in the documentation 13 | # and/or other materials provided with the distribution. 14 | # 15 | # * Neither the name of the copyright holder nor the names of its 16 | # contributors may be used to endorse or promote products derived from 17 | # this software without specific prior written permission. 18 | # 19 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 20 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 23 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 26 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 27 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | ################################################################################# 30 | # from .tvm_input_config import default_tvm_args 31 | 32 | -------------------------------------------------------------------------------- /tinyml-tinyverse/tinyml_tinyverse/common/datasets/__init__.py: -------------------------------------------------------------------------------- 1 | from .timeseries_dataset import GenericTSDataset, GenericTSDatasetReg, GenericTSDatasetAD 2 | 3 | -------------------------------------------------------------------------------- /tinyml-tinyverse/tinyml_tinyverse/common/datasets/generic_dataloaders.py: -------------------------------------------------------------------------------- 1 | ################################################################################# 2 | # Copyright (c) 2023-2024, Texas Instruments 3 | # All Rights Reserved. 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions are met: 7 | # 8 | # * Redistributions of source code must retain the above copyright notice, this 9 | # list of conditions and the following disclaimer. 10 | # 11 | # * Redistributions in binary form must reproduce the above copyright notice, 12 | # this list of conditions and the following disclaimer in the documentation 13 | # and/or other materials provided with the distribution. 14 | # 15 | # * Neither the name of the copyright holder nor the names of its 16 | # contributors may be used to endorse or promote products derived from 17 | # this software without specific prior written permission. 18 | # 19 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 20 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 23 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 26 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 27 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | ################################################################################# 30 | 31 | # This file contains a few generic data loaders that can be used to parse data 32 | -------------------------------------------------------------------------------- /tinyml-tinyverse/tinyml_tinyverse/common/models/generic_models.py: -------------------------------------------------------------------------------- 1 | ################################################################################# 2 | # Copyright (c) 2023-2024, Texas Instruments 3 | # All Rights Reserved. 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions are met: 7 | # 8 | # * Redistributions of source code must retain the above copyright notice, this 9 | # list of conditions and the following disclaimer. 10 | # 11 | # * Redistributions in binary form must reproduce the above copyright notice, 12 | # this list of conditions and the following disclaimer in the documentation 13 | # and/or other materials provided with the distribution. 14 | # 15 | # * Neither the name of the copyright holder nor the names of its 16 | # contributors may be used to endorse or promote products derived from 17 | # this software without specific prior written permission. 18 | # 19 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 20 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 23 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 26 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 27 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | ################################################################################# 30 | 31 | import yaml 32 | from .generic_classification_models import * 33 | from .generic_regression_models import * 34 | from .generic_feature_extraction_models import * 35 | from .generic_autoencoder_models import * 36 | 37 | 38 | if __name__ == '__main__': 39 | yaml.Dumper.ignore_aliases = lambda *data: True 40 | filename = 'CNN_TS_GEN_BASE_13K.yaml' 41 | with open(filename, 'w') as fp: 42 | yaml.dump(CNN_TS_GEN_BASE_13K(dict()).model_spec, fp, default_flow_style=False, sort_keys=False) 43 | 44 | filename = 'CNN_TS_GEN_BASE_6K.yaml' 45 | with open(filename, 'w') as fp: 46 | yaml.dump(CNN_TS_GEN_BASE_6K(dict()).model_spec, fp, default_flow_style=False, sort_keys=False) 47 | 48 | filename = 'CNN_TS_GEN_BASE_4K.yaml' 49 | with open(filename, 'w') as fp: 50 | yaml.dump(CNN_TS_GEN_BASE_4K(dict()).model_spec, fp, default_flow_style=False, sort_keys=False) 51 | 52 | filename = 'CNN_TS_GEN_BASE_1K.yaml' 53 | with open(filename, 'w') as fp: 54 | yaml.dump(CNN_TS_GEN_BASE_1K(dict()).model_spec, fp, default_flow_style=False, sort_keys=False) 55 | -------------------------------------------------------------------------------- /tinyml-tinyverse/tinyml_tinyverse/common/models/generic_regression_models.py: -------------------------------------------------------------------------------- 1 | from ..utils import py_utils 2 | from .generic_model_spec import GenericModelWithSpec 3 | 4 | 5 | class REG_TS_GEN_BASE_3K(GenericModelWithSpec): 6 | def __init__(self, config, input_features=512, variables=1, num_classes=2, with_input_batchnorm=True): 7 | super().__init__(config, input_features=input_features, variables=variables, 8 | with_input_batchnorm=with_input_batchnorm, num_classes=num_classes) 9 | self.model_spec = self.gen_model_spec() 10 | self._init_model_from_spec(model_spec=self.model_spec, variables=self.variables, 11 | input_features=self.input_features, num_classes=self.num_classes, 12 | with_input_batchnorm=self.with_input_batchnorm) 13 | 14 | def gen_model_spec(self): 15 | layers = py_utils.DictPlus() 16 | layers += {'0' :dict(type='BatchNormLayer', num_features=self.variables) if self.with_input_batchnorm else dict 17 | (type='IdentityLayer')} 18 | layers += {'1' :dict(type='ReshapeLayer', ndim=2)} 19 | # layers += {'1p':dict(type='MaxPoolLayer', kernel_size=(3,1), stride=(2,1))} 20 | layers += {'2' :dict(type='LinearLayer', in_features=None, out_features=self.num_classes *32)} 21 | layers += {'3' :dict(type='ReluLayer')} 22 | layers += {'4' :dict(type='LinearLayer', in_features=None, out_features=self.num_classes *16)} 23 | layers += {'5' :dict(type='ReluLayer')} 24 | layers += {'6' :dict(type='LinearLayer', in_features=None, out_features=self.num_classes *4)} 25 | layers += {'7' :dict(type='ReluLayer')} 26 | layers += {'8' :dict(type='LinearLayer', in_features=None, out_features=self.num_classes)} 27 | model_spec = dict(model_spec=layers) 28 | return model_spec 29 | 30 | -------------------------------------------------------------------------------- /tinyml-tinyverse/tinyml_tinyverse/common/transforms/__init__.py: -------------------------------------------------------------------------------- 1 | ################################################################################# 2 | # Copyright (c) 2023-2024, Texas Instruments 3 | # All Rights Reserved. 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions are met: 7 | # 8 | # * Redistributions of source code must retain the above copyright notice, this 9 | # list of conditions and the following disclaimer. 10 | # 11 | # * Redistributions in binary form must reproduce the above copyright notice, 12 | # this list of conditions and the following disclaimer in the documentation 13 | # and/or other materials provided with the distribution. 14 | # 15 | # * Neither the name of the copyright holder nor the names of its 16 | # contributors may be used to endorse or promote products derived from 17 | # this software without specific prior written permission. 18 | # 19 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 20 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 23 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 26 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 27 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | ################################################################################# 30 | 31 | -------------------------------------------------------------------------------- /tinyml-tinyverse/tinyml_tinyverse/common/transforms/basic_transforms.py: -------------------------------------------------------------------------------- 1 | ################################################################################# 2 | # Copyright (c) 2023-2024, Texas Instruments 3 | # All Rights Reserved. 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions are met: 7 | # 8 | # * Redistributions of source code must retain the above copyright notice, this 9 | # list of conditions and the following disclaimer. 10 | # 11 | # * Redistributions in binary form must reproduce the above copyright notice, 12 | # this list of conditions and the following disclaimer in the documentation 13 | # and/or other materials provided with the distribution. 14 | # 15 | # * Neither the name of the copyright holder nor the names of its 16 | # contributors may be used to endorse or promote products derived from 17 | # this software without specific prior written permission. 18 | # 19 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 20 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 23 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 26 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 27 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | ################################################################################# 30 | import numpy as np 31 | 32 | 33 | def SimpleWindow(x, window_size=100, stride=50, keep_short_tails=False): 34 | # if keep_short_tails is set to True, the slices shorter than window_size at the end of the result will be kept 35 | # length = x.size(0) 36 | length, channels = x.shape 37 | range_end = length 38 | if not keep_short_tails: 39 | range_end = length - window_size + 1 40 | splits = np.zeros((channels, (range_end+stride-1)//stride, window_size)) 41 | x = x.T 42 | 43 | for ax in range(channels): 44 | idx = 0 45 | for slice_start in range(0, range_end, stride): 46 | slice_end = min(length, slice_start + window_size) 47 | length_of_window = slice_end-slice_start 48 | splits[ax][idx][:length_of_window] = x[ax][slice_start:slice_end] 49 | idx += 1 50 | x = splits.transpose(1,2,0) 51 | return x 52 | 53 | 54 | def Downsample(x, sampling_rate, new_sr): 55 | ''' 56 | if x.ndim == 1: 57 | return x[::int(sampling_rate // new_sr)] # Downsample the 1d array before windowing 58 | else: 59 | return x[:, ::int(sampling_rate // new_sr)] # Downsample along the time dimension after windowing 60 | ''' 61 | channels = x.shape[1] 62 | x = x.T 63 | x_scratch = [] 64 | for ax in range(channels): 65 | x_scratch.append(x[ax][::int(sampling_rate//new_sr)]) 66 | x = np.array(x_scratch).T 67 | return x # DownSampling is being done only before windowing so for now it doesn't matter 68 | 69 | class Jittering(object): 70 | def __init__(self, sigma): 71 | assert isinstance(sigma, (float, tuple)) 72 | self.sigma = sigma 73 | 74 | def __call__(self, sample): 75 | #print(sample) 76 | data, label = sample['data'], sample['label'] 77 | if isinstance(self.sigma, float): 78 | myNoise = np.random.normal(loc=0, scale=self.sigma, size=data.shape) 79 | data = data+myNoise 80 | return {'data': data, 'label': label} -------------------------------------------------------------------------------- /tinyml-tinyverse/tinyml_tinyverse/common/utils/__init__.py: -------------------------------------------------------------------------------- 1 | ################################################################################# 2 | # Copyright (c) 2023-2024, Texas Instruments 3 | # All Rights Reserved. 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions are met: 7 | # 8 | # * Redistributions of source code must retain the above copyright notice, this 9 | # list of conditions and the following disclaimer. 10 | # 11 | # * Redistributions in binary form must reproduce the above copyright notice, 12 | # this list of conditions and the following disclaimer in the documentation 13 | # and/or other materials provided with the distribution. 14 | # 15 | # * Neither the name of the copyright holder nor the names of its 16 | # contributors may be used to endorse or promote products derived from 17 | # this software without specific prior written permission. 18 | # 19 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 20 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 23 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 26 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 27 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | ################################################################################# 30 | 31 | -------------------------------------------------------------------------------- /tinyml-tinyverse/tinyml_tinyverse/common/utils/py_utils.py: -------------------------------------------------------------------------------- 1 | ################################################################################# 2 | # Copyright (c) 2023-2024, Texas Instruments 3 | # All Rights Reserved. 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions are met: 7 | # 8 | # * Redistributions of source code must retain the above copyright notice, this 9 | # list of conditions and the following disclaimer. 10 | # 11 | # * Redistributions in binary form must reproduce the above copyright notice, 12 | # this list of conditions and the following disclaimer in the documentation 13 | # and/or other materials provided with the distribution. 14 | # 15 | # * Neither the name of the copyright holder nor the names of its 16 | # contributors may be used to endorse or promote products derived from 17 | # this software without specific prior written permission. 18 | # 19 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 20 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 23 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 26 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 27 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | ################################################################################# 30 | 31 | 32 | class DictPlus(dict): 33 | def __init__(self, *args, force_update=False, **kwargs): 34 | super().__init__(*args, **kwargs) 35 | self.force_update = force_update 36 | 37 | def __iadd__(self, other): 38 | if not self.force_update: 39 | for key in other: 40 | if key in self: 41 | raise RuntimeError(f'force_update is disabled and key={key} is already preset inthe dictionary') 42 | # 43 | # 44 | # 45 | self.update(other) 46 | return self 47 | -------------------------------------------------------------------------------- /tinyml-tinyverse/tinyml_tinyverse/references/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TexasInstruments/tinyml-tensorlab/3a2d9e8eefdb3ee560d42aa8c01e31eeaf79f166/tinyml-tinyverse/tinyml_tinyverse/references/__init__.py -------------------------------------------------------------------------------- /tinyml-tinyverse/tinyml_tinyverse/references/common/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TexasInstruments/tinyml-tensorlab/3a2d9e8eefdb3ee560d42aa8c01e31eeaf79f166/tinyml-tinyverse/tinyml_tinyverse/references/common/__init__.py -------------------------------------------------------------------------------- /tinyml-tinyverse/tinyml_tinyverse/references/timeseries_anomalydetection/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TexasInstruments/tinyml-tensorlab/3a2d9e8eefdb3ee560d42aa8c01e31eeaf79f166/tinyml-tinyverse/tinyml_tinyverse/references/timeseries_anomalydetection/__init__.py -------------------------------------------------------------------------------- /tinyml-tinyverse/tinyml_tinyverse/references/timeseries_classification/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TexasInstruments/tinyml-tensorlab/3a2d9e8eefdb3ee560d42aa8c01e31eeaf79f166/tinyml-tinyverse/tinyml_tinyverse/references/timeseries_classification/__init__.py -------------------------------------------------------------------------------- /tinyml-tinyverse/tinyml_tinyverse/references/timeseries_regression/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TexasInstruments/tinyml-tensorlab/3a2d9e8eefdb3ee560d42aa8c01e31eeaf79f166/tinyml-tinyverse/tinyml_tinyverse/references/timeseries_regression/__init__.py -------------------------------------------------------------------------------- /tinyml-tinyverse/tinyml_tinyverse/references/version.py: -------------------------------------------------------------------------------- 1 | ################################################################################# 2 | # Copyright (c) 2023-2024, Texas Instruments 3 | # All Rights Reserved. 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions are met: 7 | # 8 | # * Redistributions of source code must retain the above copyright notice, this 9 | # list of conditions and the following disclaimer. 10 | # 11 | # * Redistributions in binary form must reproduce the above copyright notice, 12 | # this list of conditions and the following disclaimer in the documentation 13 | # and/or other materials provided with the distribution. 14 | # 15 | # * Neither the name of the copyright holder nor the names of its 16 | # contributors may be used to endorse or promote products derived from 17 | # this software without specific prior written permission. 18 | # 19 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 20 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 23 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 26 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 27 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | ################################################################################# 30 | 31 | __version__ = '1.0.0' 32 | 33 | 34 | def get_version(): 35 | return __version__ 36 | 37 | 38 | def get_version_str(delimiter='_'): 39 | version_str = delimiter.join([f'{r:0>2}' for r in __version__.split('.')]) 40 | return version_str 41 | --------------------------------------------------------------------------------