Giter Site home page Giter Site logo

philippmatthes / tmd Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 0.0 7.91 MB

TFLite models and Flutter library for transport mode detection on mobile devices. (IEEE IoTaIS 2022)

License: MIT License

Ruby 0.07% Swift 1.60% Jupyter Notebook 96.96% C 0.10% Python 0.32% Dart 0.95% Kotlin 0.01% Objective-C 0.01%
flutter flutter-library shl tmd transport-mode-detection shl-dataset

tmd's Introduction

Transport Mode Detection for Smartphones

TFLite Machine learning models trained for transport mode detection (TMD) on smartphones. This library provides a simple API to use these models in your Flutter app. The models were trained and evaluated on the SHL (Sussex-Huawei-Locomotion) dataset.

Installing

Add this library to your pubspec.yaml via GitHub:

dependencies:
  tmd:
    git:
      url: https://github.com/philippmatthes/tmd
      ref: main

Example Usage

import 'package:tmd/tmd.dart';

void main() async {
  final tmd = TMD();
  final stream = await tmd.startListeningForChanges()
  stream.listen((newMode) {
    print(newMode); // New transport mode detected
  });
}

There is also the option to specify how often the model should be evaluated, and how often the changed transport mode should be cross-checked before reporting the change.

import 'package:tmd/tmd.dart';

void main() async {
  final tmd = TMD();
  final stream = await tmd.startListeningForChanges(
    // Notify only if a new transport mode was detected that many
    // consecutive times. This will improve the stability at the
    // expense of a less frequent notification.
    nChangedForNotification: 5,
    // The inference period defines how often the transport mode
    // is inferred. This will also affect the notification frequency.
    // Note that the inference period also impacts the battery life.
    // It is recommended to not go below 0.5 seconds.
    inferencePeriod: const Duration(milliseconds: 1000),
  );
  stream.listen((newMode) {
    print(newMode); // New transport mode detected
  });
}

Designed for Low Resource Usage

Battery Impact

Read our paper to learn more about how we optimized the model for low resource usage: Selecting Resource-Efficient ML Models for Transport Mode Detection on Mobile Devices.

Known Issues

  • Currently, the IMU sensor stream is kept active even when the transport mode detection does not need it.
  • Transport mode "car" may be detected instead of "still" when the smartphone lays flat on the table.
  • The detection may vary between devices depending on the sensor quality and sampling rate.

Please help us improve this library by cross-checking results and reporting any issues you encounter.

TFLite Models Download

The model in the first row is the model used by default in this library.

Model ID Type Pooling Optimizer Optimization Depth LR Val. Acc. (%) Download
4ad2e7 1d ResNetV1 max adam Pruning & Separable Layers 2 0.010 84.91 Google Drive
4ad2e7 1d ResNetV1 max adam Pruning 2 0.010 84.38 Google Drive
4ad2e7 1d ResNetV1 max adam - 2 0.010 84.34 Google Drive
6af8a1 1d ResNetV1 max adam - 4 0.010 84.18 Google Drive
7cfd66 1d ResNetV1 max sgd - 2 0.100 84.18 Google Drive
968ca3 1d ResNetV1 max sgd - 2 0.100 84.03 Google Drive
e6c367 1d ResNetV1 avg adam - 3 0.001 83.69 Google Drive
998822 1d ResNetV2 max sgd - 2 0.010 82.92 Google Drive
752315 2d ResNetV2 avg rmsprop - 2 0.010 81.33 Google Drive
35d171 2d ResNetV1 avg adam - 2 0.010 81.07 Google Drive
ea7037 1d ResNetV1 avg adam - 3 0.001 81.01 Google Drive
cb5048 2d ResNetV1 max adam - 2 0.010 78.96 Google Drive

All models were trained and evaluated on the SHL dataset. If any of the download links do not work, here is a backup: Google Drive. Please open an issue in this case.

Citing this Work

@inproceedings{matthes2022selecting,
  title={Selecting Resource-Efficient ML Models for Transport Mode Detection on Mobile Devices},
  author={Matthes, Philipp and Springer, Thomas},
  booktitle={2022 IEEE International Conference on Internet of Things and Intelligence Systems (IoTaIS)},
  pages={135--141},
  year={2022},
  organization={IEEE}
}

tmd's People

Contributors

philippmatthes avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.