deep learning in iot - files.devnetwork.cloud · iot can be divided primarily into following four...

43
Deep Learning in IoT Avid Farhoodfar & Dev Bhattacharya

Upload: others

Post on 07-Aug-2020

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Deep Learning in IoT - files.devnetwork.cloud · IoT can be divided primarily into following four stages: Sensors, Actuators, Controllers (limited resources, limited intelligence)

Deep Learning in IoT

Avid Farhoodfar & Dev Bhattacharya

Page 2: Deep Learning in IoT - files.devnetwork.cloud · IoT can be divided primarily into following four stages: Sensors, Actuators, Controllers (limited resources, limited intelligence)

Agenda ● IoT architecture and stages (Example case of Fire & Smoke detection)

● IoT stage functions

● Summary of IoT stages

● Artificial intelligence, Machine learning & Deep learning

● How to apply TensorFlow to do Machine learning and Deep Learning

● How to apply TensorFlow Lite

● Demo - SparkFun Edge Microcontroller

Page 3: Deep Learning in IoT - files.devnetwork.cloud · IoT can be divided primarily into following four stages: Sensors, Actuators, Controllers (limited resources, limited intelligence)

What are stages in IoT?

Page 4: Deep Learning in IoT - files.devnetwork.cloud · IoT can be divided primarily into following four stages: Sensors, Actuators, Controllers (limited resources, limited intelligence)

IoT stages IoT can be divided primarily into following four stages:

● Sensors, Actuators, Controllers (limited resources, limited

intelligence)

● Data Aggregators, Gateways (data aggregation, data

acquisition)

● Edge (analytics, preprocessing)

● Cloud (analytics, processing, management)

Page 5: Deep Learning in IoT - files.devnetwork.cloud · IoT can be divided primarily into following four stages: Sensors, Actuators, Controllers (limited resources, limited intelligence)

IoT stages IoT can be divided primarily into following four stages as shown in

the following diagram:

Sensors,

Actuators,

Controllers

(limited

resources,

limited

intelligence)

(Analytics,

pre-

processing)

(Analytics,

Processing)

Data

Aggregators,

Gateways

Cloud

Edge

(data

aggregation,

data

acquisition)

Page 6: Deep Learning in IoT - files.devnetwork.cloud · IoT can be divided primarily into following four stages: Sensors, Actuators, Controllers (limited resources, limited intelligence)

Sensors, actuators & controllers

Page 7: Deep Learning in IoT - files.devnetwork.cloud · IoT can be divided primarily into following four stages: Sensors, Actuators, Controllers (limited resources, limited intelligence)

Sensors, Actuators & Controllers ● Sensors

○ Smart dust1 combines smoke sensing (ionization and photo electric)2,

computing, sensing of humidity, temperature, CO, CO2 & wind speed, wireless

communication capabilities and autonomous power supply within small

envelope at low cost in large volume of deployment.

Large number of smart dust sensors will be deployed and will be connected in

mesh configuration and will communicate when smoke is detected. Some of

the smart dust sensors can be more intelligent node with GPS and will be able

to provide time stamp, exact location and direction of smoke and wind travel

by combination of data from the intelligent nodes.

○ Vision sensors for smoke and fire detection

○ UAV and/or drone to augment and speed up detection of smoke and fire from

Aerial

1 https://now.northropgrumman.com/mems-and-smart-dust-the-big-potential-of-a-tiny-future/

2

• Ionization smoke sensors – are generally mode responsive to flaming fires

• Photo electric smoke sensors – are generally mode responsive to smoldering fires

Page 8: Deep Learning in IoT - files.devnetwork.cloud · IoT can be divided primarily into following four stages: Sensors, Actuators, Controllers (limited resources, limited intelligence)

Sensors, Actuators & Controllers ● Machine learning

○ Activity classification with a designed feature extraction, data driven, better classification than

rule based but not highly accurate.

Data from sensors

Smoke

Fire Neural

network

Designed feature extraction

(handcrafted by human)

Trained Classifier

Smoke

Page 9: Deep Learning in IoT - files.devnetwork.cloud · IoT can be divided primarily into following four stages: Sensors, Actuators, Controllers (limited resources, limited intelligence)

Sensors, Actuators & Controllers ● Deep learning

○ Activity classification with a trained feature extraction for low level and high level features

and trained classifier for full classification of activity, provides highly accurate classification

Data from sensors Deep learning (DL)

Trained

feature

extraction

(Coarse low

level

features)

Smoke

Trained

feature

extraction

(Higher

level

features)

Trained

Classifier

(Full

classification

of activity)

Page 10: Deep Learning in IoT - files.devnetwork.cloud · IoT can be divided primarily into following four stages: Sensors, Actuators, Controllers (limited resources, limited intelligence)

Data Aggregator, Gateway,

Concentrators: Data Aggregation,

Measurement, Data Acquisition

Page 11: Deep Learning in IoT - files.devnetwork.cloud · IoT can be divided primarily into following four stages: Sensors, Actuators, Controllers (limited resources, limited intelligence)

Data Aggregator ● Data Aggregator does the combined classification from

various sensing sources

o The goal is to send the smart dust and other sensors’ data to our

future microcontroller which we have plan to design. The idea is taken

from sparkfun Edge board which you see in Demo section.

○ Selects and classifies data by filtering data, detecting outliers and

rejecting them

○ Low latency for aggregating data

○ Energy efficient

Page 12: Deep Learning in IoT - files.devnetwork.cloud · IoT can be divided primarily into following four stages: Sensors, Actuators, Controllers (limited resources, limited intelligence)

CNN Model Using Deep Learning for

Fire & Smoke Detection

Page 13: Deep Learning in IoT - files.devnetwork.cloud · IoT can be divided primarily into following four stages: Sensors, Actuators, Controllers (limited resources, limited intelligence)

CNN Model

Fully Connected

Feedforward network

Fire and

smoke

detection Convolution

Max Pooling

Convolution

Max Pooling

Flattened

Can

repeat

many

times

Fire and

smoke

images

Page 14: Deep Learning in IoT - files.devnetwork.cloud · IoT can be divided primarily into following four stages: Sensors, Actuators, Controllers (limited resources, limited intelligence)

Edge: Analytics & Preprocessing

Page 15: Deep Learning in IoT - files.devnetwork.cloud · IoT can be divided primarily into following four stages: Sensors, Actuators, Controllers (limited resources, limited intelligence)

Edge: Analytics & Preprocessing –

Model for Edge

Functionality for Edge application

● Analytics at the Edge

● Edge based computing and does preprocessing for cloud

● Realtime response and lower latency

● Better localized accuracy for IoT

● Increased performance

● Uses TFlite

● Useful for application like smoke, fire detection that needs real

time response

Page 16: Deep Learning in IoT - files.devnetwork.cloud · IoT can be divided primarily into following four stages: Sensors, Actuators, Controllers (limited resources, limited intelligence)

Edge: Analytics & Preprocessing ● Deep learning way of finding Analytics at the edge

○ Edge servers are smaller in size with limited storage and kept at various locations

○ Selection of appropriate model allows low latency, real time operation and high QoS

Classification,

critical data trend

and analytics on

Smoke and fire

detection data

Smoke and

fire detection

in presence

of fog, cloud

in a short

time

Deep learning (DL)

Trained

combined

detection with

monitoring

feature

extraction

(Coarse low

level features)

Trained

combined

detection with

monitoring

feature

extraction

(Higher

level

features)

Trained Classifier

combined

detection with

monitoring

(Classification of

fire and smoke)

Environment test

data such as Fog,

Cloud

Page 17: Deep Learning in IoT - files.devnetwork.cloud · IoT can be divided primarily into following four stages: Sensors, Actuators, Controllers (limited resources, limited intelligence)

CNN Model for Edge

Fully Connected

Feedforward network

Fire and

smoke

detection Convolution

Max Pooling

Convolution

Max Pooling

Flattened

Repeat 2

times

Fire and

smoke

images

Page 18: Deep Learning in IoT - files.devnetwork.cloud · IoT can be divided primarily into following four stages: Sensors, Actuators, Controllers (limited resources, limited intelligence)

Cloud: Analytics & Processing

Page 19: Deep Learning in IoT - files.devnetwork.cloud · IoT can be divided primarily into following four stages: Sensors, Actuators, Controllers (limited resources, limited intelligence)

CNN for Cloud model

Fully Connected

Feedforward network

Fire and

smoke

detection Convolution

Max Pooling

Convolution

Max Pooling

Flattened

Repeat 64

times

Fire and

smoke

images

Page 20: Deep Learning in IoT - files.devnetwork.cloud · IoT can be divided primarily into following four stages: Sensors, Actuators, Controllers (limited resources, limited intelligence)

Cloud: Analytics & Processing ● Analytics & prediction

● Full processing of all the data and classification on a full model

● Combines short term data with long term data to provide thorough

analytics and prediction

● Predicts smoke and fire by looking at long term and short term data

● Long term data may include similar data at same time in past history

(months, years) that relates to similar temperature, humidity, wind speed

fog etc.

● Short term data will include all data from all the sensors on the ground and

on aerial

● Uses full TF for analysis, Higher accuracy of prediction

● Relatively long latency compared to Edge

Page 21: Deep Learning in IoT - files.devnetwork.cloud · IoT can be divided primarily into following four stages: Sensors, Actuators, Controllers (limited resources, limited intelligence)

Cloud: Analytics & Prediction

Deep learning way of Prediction from cloud with higher accuracy

○ Cloud servers is very large in size and is centralized

○ Selection of appropriate model allows high compute capability and large data storage

Smoke and fire

detection in

presence of fog,

cloud in a short

time

Smoke and

fire detection

in presence

of fog, cloud

with higher

prediction

accuracy

based on

short term

and long

term data

Deep learning (DL)

Trained

combined

detection with

monitoring

feature

extraction

(Coarse low

level features)

Trained

combined

detection with

monitoring

feature

extraction

(Higher

level

features)

Trained Classifier

combined

detection with

monitoring

(Full classification

of fire and smoke)

Environment test

data such as Fog,

Cloud

Long term data

for months and

years

Page 22: Deep Learning in IoT - files.devnetwork.cloud · IoT can be divided primarily into following four stages: Sensors, Actuators, Controllers (limited resources, limited intelligence)

Proposed Model Effectiveness

● CNN limitations ● CNNs lays in the amount of data you provide to them. CNNs

perform poorly with less data. CNNs could have very large

number (millions in some cases) of parameters. With small

dataset, would run into an over-fitting problem.

● CNNs is more strong and provides better performance with

large set of data.

● Currently we have very limited datasets. Once we get enough

datasets, we will be able to accurately evaluate our model.

Page 23: Deep Learning in IoT - files.devnetwork.cloud · IoT can be divided primarily into following four stages: Sensors, Actuators, Controllers (limited resources, limited intelligence)
Page 24: Deep Learning in IoT - files.devnetwork.cloud · IoT can be divided primarily into following four stages: Sensors, Actuators, Controllers (limited resources, limited intelligence)

What is DL & Demo?

Page 25: Deep Learning in IoT - files.devnetwork.cloud · IoT can be divided primarily into following four stages: Sensors, Actuators, Controllers (limited resources, limited intelligence)

What’s a machine learning?

Use algorithms to learn from data (a.k.a Training)

Algorithms are known as models

Models perform prediction (a.k.a inference)

Model

Output

“Fire”

25

Page 26: Deep Learning in IoT - files.devnetwork.cloud · IoT can be divided primarily into following four stages: Sensors, Actuators, Controllers (limited resources, limited intelligence)

Fire – Smoke - Dataset For my model I am using Fire – Smoke dataset.

Fire-Smoke-Dataset is a dataset collected in order to train machine learning

model to recognize Fire, smoke, and neutral(images without fire or smoke) features.

This a dataset containing about 3000 images and 3 classes which include:

• Fire

• Smoke

• Neutral

There are 1000 images in each category and 900 for train and 100 for testing

Page 27: Deep Learning in IoT - files.devnetwork.cloud · IoT can be divided primarily into following four stages: Sensors, Actuators, Controllers (limited resources, limited intelligence)

What’s a machine learning?

Use labeled data to improve models

labeled data = Input data + predictions

Errors used to improve the model

We need a Framework to make machine

learning predictions easier

Model

Output

“Fire”

“Fire”

Error

27

Page 28: Deep Learning in IoT - files.devnetwork.cloud · IoT can be divided primarily into following four stages: Sensors, Actuators, Controllers (limited resources, limited intelligence)

TensorFlow

TensorFlow is google’s framework for

machine learning.

It makes it easy to build and train

neural networks.

It is cross platform, works with CPUs, GPUs,

TPUs, as well as Mobile devices, and

Embedded Platforms.

Model

Output

“Fire”

“Fire”

Error

28

Page 29: Deep Learning in IoT - files.devnetwork.cloud · IoT can be divided primarily into following four stages: Sensors, Actuators, Controllers (limited resources, limited intelligence)

TensorFlow builts and Train Neural Networks

CO

HEAT

Optical

0.64

0.75

0.4

0.87 “Fire”

Page 30: Deep Learning in IoT - files.devnetwork.cloud · IoT can be divided primarily into following four stages: Sensors, Actuators, Controllers (limited resources, limited intelligence)

CO

Optical

HEAT

“Fire”

NOT “Fire”

Page 31: Deep Learning in IoT - files.devnetwork.cloud · IoT can be divided primarily into following four stages: Sensors, Actuators, Controllers (limited resources, limited intelligence)

NOT “Fire”

“Fire”

CO

Optical

HEAT

Page 32: Deep Learning in IoT - files.devnetwork.cloud · IoT can be divided primarily into following four stages: Sensors, Actuators, Controllers (limited resources, limited intelligence)

32

Page 33: Deep Learning in IoT - files.devnetwork.cloud · IoT can be divided primarily into following four stages: Sensors, Actuators, Controllers (limited resources, limited intelligence)

33

Page 34: Deep Learning in IoT - files.devnetwork.cloud · IoT can be divided primarily into following four stages: Sensors, Actuators, Controllers (limited resources, limited intelligence)

34

Page 35: Deep Learning in IoT - files.devnetwork.cloud · IoT can be divided primarily into following four stages: Sensors, Actuators, Controllers (limited resources, limited intelligence)
Page 36: Deep Learning in IoT - files.devnetwork.cloud · IoT can be divided primarily into following four stages: Sensors, Actuators, Controllers (limited resources, limited intelligence)

Convolution layers apply specific filters to the image

Pooling layers downsample the image data

Max Pooling keeps feature map to get its maximum & discard others

FC layers perform classification to features, every node in the layer is connected to

every node in the preceding layer

softmax

Page 37: Deep Learning in IoT - files.devnetwork.cloud · IoT can be divided primarily into following four stages: Sensors, Actuators, Controllers (limited resources, limited intelligence)

Binary classification given a problem with 3 possible solutions, 3 binary classifiers, outcome is only ONE.

Softmax assigns decimal probabilities to each class in a multi-class problem.

Those decimal probabilities must add up to 1.0. P Fire + P Smoke + P Neutral = 1.0

softmax

Page 38: Deep Learning in IoT - files.devnetwork.cloud · IoT can be divided primarily into following four stages: Sensors, Actuators, Controllers (limited resources, limited intelligence)

Some of the prediction results

Page 39: Deep Learning in IoT - files.devnetwork.cloud · IoT can be divided primarily into following four stages: Sensors, Actuators, Controllers (limited resources, limited intelligence)

DEMO TIME

TensorFlow Lite for

Microcontrollers

Smaller, cheaper & wider range of devices

39

Page 40: Deep Learning in IoT - files.devnetwork.cloud · IoT can be divided primarily into following four stages: Sensors, Actuators, Controllers (limited resources, limited intelligence)

This is about Tiny models on tiny computers!

● Microcontrollers are everywhere

● Speech researchers were pioneers

● Models just tens of kilobytes

40

Page 41: Deep Learning in IoT - files.devnetwork.cloud · IoT can be divided primarily into following four stages: Sensors, Actuators, Controllers (limited resources, limited intelligence)

Here’s one I have in my pocket

Get ready for a live demo!

https://www.sparkfun.com/products/15170

384KB RAM, 1MB Flash,

Low single-digit milliwatt power usage

Days on a coin battery!

41

Page 42: Deep Learning in IoT - files.devnetwork.cloud · IoT can be divided primarily into following four stages: Sensors, Actuators, Controllers (limited resources, limited intelligence)

Why is this important?

(1) This is running entirely locally on the embedded chip.

We don’t need to have any internet connection

(2) The model itself is not quite 13 KB but it takes 20KB flash

storage on this device

(3) And the footprint of TensorFlow Lite for

Microcontrollers is only another 25 KB

42

Page 43: Deep Learning in IoT - files.devnetwork.cloud · IoT can be divided primarily into following four stages: Sensors, Actuators, Controllers (limited resources, limited intelligence)

Conclusion

● IoT architecture and various stages are presented.

● Sensor and aggregation stages functions are discussed.

● CNN model for fire and smoke detection is proposed.

● Report some Prediction Results

● SparkFun Edge working with TensorFlow Lite for future design

● In our future work, we will delve into other approaches for further

improvement for our IoT platform.