0% found this document useful (0 votes)
3 views95 pages

(Slide) Module 42

.

Uploaded by

Kristian Hasa
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views95 pages

(Slide) Module 42

.

Uploaded by

Kristian Hasa
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

AI for

Youth
Computer Vision: Use-Case
Walkthrough

1
Legal Disclaimers
The Intel® Digital Readiness Programs and Intel® AI for Youth program are developed by Intel Corporation.

© Intel Corporation. Intel, the Intel logo, and other Intel marks are trademarks of Intel Corporation or its subsidiaries. Other names and brands
may be claimed as the property of others. All rights reserved. Program dates and lesson plans are subject to change.

Intel technologies may require enabled hardware, software, or service activation.

No product or component can be absolutely secure.

Results have been estimated or simulated.

Intel does not control or audit third-party data. You should consult other sources to evaluate accuracy.

Your costs and results may vary.

2
Recap
1. Data Acquisition and Exploration

2. ROI, Contour, Thresholding and Image Masking

3. Introduction to CNN

4. Convolution Operations

5. Fully Connected layers


What is Data Acquisition?

Raw information collecting or


and facts obtaining data

Data acquisition is the process of collecting


data from relevant sources to be used for
further processing.

4
What is Data Exploration?
▪ Data exploration primarily includes visualization of data to uncover
insights, patterns, and anomalies, establish relationships between
variables and identify outliers in a dataset.
▪ Data exploration is the first step of data analysis in Computer Vision.
▪ Data characteristics:
▪ Size/volume
▪ Completeness of the data
▪ Correctness of the data
▪ Relationships between variables
These are some of the data characteristics that we can identify and analyze
with data exploration.

What Is Data Exploration & Why Is It Important? | Alteryx. (n.d.). Alteryx. [Link]

5
Region of Interest(ROI)

▪ A Region of Interest (ROI) is a portion of an image


that you want to filter or operate on in some way.
▪ The process of defining the ROI in an input frame is
known as ROI Segmentation.
▪ In ROI Segmentation, we select a specific region in
the frame and draw the rectangle-shaped ROI on
the frame.
▪ Segmentation separates background from
foreground i.e our object

6
Contour

▪ A Contour means an outline representing or say bounding a shape of an object.


▪ Contours works best after thresholding the ROI frame

7
Thresholding

▪ Thresholding is a simple form of image segmentation.


▪ It is a process of transforming a grayscale or rgb(red
green blue) image into a binary image.
▪ After thresholding the rgb frame, it becomes easy for the
program to find contours.
▪ The color of the object of interest in the ROI will be
either
▪ Black(in simple Binary Threshing) or
▪ White(in Inverse Binary Threshing)

RBG Frame Binary Threshold Frame

8
Image Masking

Original image before masking Mask Output image after masking

9
How CNN works!

When an image enters the CNN, it is


converted into pixels

Convolution + ReLU Layers: Simple features such as


edges and shapes are extracted in the first layer Fully Connected Layer: The deeper we travel in
the CNN, more complex features are extracted,
such as, faces and objects.

Pooling Layer: The next layer detects complex


features such as corners and combinational
edges
Do convolutional neural networks mimic the human visual system? | MSAIL , How convolutional neural network see the world - A survey of convolutional neural network visualization methods

10
CNN Architecture: Convolution Layers

What is convolution Operation?

Convolution is an operation performed on two functions,


ex: f and g, which produces a third function.

11
Fully Connected Layers

What are they called Fully Connected Layers?

They are called fully connected layers because each node


in these layers are connected to every other node in the
next layer.

Arc, A. (2021, December 7). Convolutional Neural Network - Towards Data Science. Medium. Retrieved October 3, 2022, from [Link]

12
You will be able to answer the following:

1. How to convert a real-world problem statement to an AI problem statement?

2. How to map the stages of the AI project cycle with the computer vision project?

3. How to identify image segmentation in a Geospatial dataset?

4. Which model is best suited for classification in Geospatial data?

13
Module Sections

14
Problem Scoping

1. Problem Scoping

2. Data Acquisition

3. Data Exploration

4. Modeling

5. Evaluation and Deployment


Can you identify these images?

Hint- They aren’t from an “End of the world movie”

16
These images are forest fires from three
different continents.

17
Forest Fires – 2021

California 2021 Greece - 2021 Turkey-2021

18
Images of forest fire from space

California 2021 Greece - 2021 Turkey-2021

19
Let’s look at a few more natural disasters
between 2020 and 2021.

20
Natural Disasters – 2021

Cyclone Tauktae – 2021 Floods – 2021


Indian subcontinent Europe

21
Floods – 2021
In 2021 a total number of 432 catastrophic events were recorded globally.

223 out of these were


flash floods.

The average number of


floods per year from 2000 to
2020, was 163.
Australian Floods-2019

22
Forest Fires – 2021
In 2021 a total number of 432 catastrophic events were recorded globally.

More than 48,725


forest fires were
recorded in the USA
alone.
The total number of
emissions caused due to
forest fires exceeded 1780
Mega Tonne of CO2.

23
What do you think cause these natural
disasters?

24
Do you think these disasters are natural
or human-induced?

25
Can you identify these images? What do they
represent?

26
Can you identify these images? What do they
represent?

Retreating Glacier in Alaska

27
Melting Ice

Rink Glacier, Greenland – Retreat between 2007 to 2009

28
Activity: Visualizing the
change in the landscape of
glaciers
15 minutes
Glacier landscape – Visualization
Instructions
▪ Go to the following link :
[Link]
ves/global-ice-viewer/#/

▪ Select the glacier which you want


to visualize from the 4 options
▪ Glaciers
▪ Greenland and Iceland
▪ The Arctic
▪ Antarctica

▪ Select a specific glacier which


NASA - Global Ice Viewer
you want to visualize.

30
Can you identify a link between the two images?

Floods – 2021
Retreating Glacier in Alaska Europe

31
Can you identify a link between the two images?

Retreating Glacier in Alaska


Floods – 2021
Europe

As the glaciers in the poles melt, the sea level rises, which results in irregular rainfalls
and floods in low-lying areas.

32
What causes the ice to melt and the forests to burn?

33
Let’s understand how the global
temperature is rising.

34
Let’s meet Jessica !

30 KM

Let’s say the distance between Jessica’s home and her school is 30 km (18 miles).

35
Jessica owns a car which runs on fossil fuel.

30 KM

Her car produces 120 grams of CO2 per KM. Hence, the total carbon her car
produces amounts to:
120 (grams) * 30 (km)= 3.6 kg CO2

36
Trees absorb Carbon dioxide from the atmosphere.

30 KM

An average 40-year-old tree absorbs 70 grams of CO2 per day. Hence, we


need
3600/70 = ~ 51 trees to absorb 3.6 Kg of carbon.
37
Carbon Producers vs. Carbon Sinks
Carbon Producers Carbon Sinks

Jessica’s Car
Trees around Jessica’s home
produces carbons
and school absorb carbon
dioxide.

38
Carbon Producers vs. Carbon Sinks
Carbon Producers Carbon Sinks

Vehicles Industries

Trees Oceans

Oil Field

39
Therefore, we heavily rely on trees and
oceans to absorb Carbon Dioxide from
the atmosphere.

40
What would happen if we lost
Carbon sinks?

41
Let’s say Jessica’s district is rapidly developing.

30 KM

As the district grows, there is an increasing demand for land. This has led to the
felling of several trees to build new homes

42
What happens in the absence of Carbon Sinks

All the carbon accumulates in the


atmosphere or ends up in the ocean.

43
The carbon that stays in the atmosphere
causes the increase in global temperature

44
What happens when the global temperature rises ?

Tsunami

Forest fires

Rising global Natural disasters


temperature lead to loss of
habitats and
livelihood.
Floods
45
Global Climate
Let’s watch a quick video !

Summary

▪ This video discusses several effects of


global warming and its direct impact on
human life
▪ It correlates natural disasters to global
warming

The Global Climate 2015-2019-World Meteorological Organization - WMO

The Global Climate 2015-2019 - YouTube. (2022). Retrieved 6 September 2022, from [Link]

46
Now that we understand the significance
of carbon sinks let’s try to leverage AI to
protect them!

47
Recall AI Project Cycle!

Problem Data
Evaluation
Scoping Exploration

Data Deployment
Acquisition Modeling

48
What is deforestation?

▪ The action of
clearing a wide
area of trees

Visualizing Deforestation- Madagascar

49
Infographics on Deforestation

50
How can we leverage AI to stop
deforestation?

51
AI problem statement

Original Satellite Images Masked image classifying deforestation

Identifying deforestation through satellite images of forests with the help of computer vision.

52
How can this solve the problem?

Original Satellite Images Masked image classifying deforestation

53
Data Acquisition
1. Problem Scoping

2. Data Acquisition

3. Data Exploration

4. Modeling

5. Evaluation and Deployment


Let’s understand the acquired dataset!

55
Dataset folders

Original Satellite Images

Two sub-folder in the “Dataset” folder

Annotated Masked Satellite Images


56
Paired Images

Pair 1 Pair 2

Every original satellite image in the folder has an annotated masked image.

57
We have 322 such pairs!

58
Attributes of Images
512 Pixels

512 Pixels
512 Pixels 512 Pixels
Original Satellite Images Masked Satellite Images
59
Hence, we have 512*512
=
262,144 pixels in each image

60
Hands-on Session:
Refer to [Jupyter Notebooks-Youth] Deforestation
Monitoring
Importing images to Jupyter notebook

▪ Building function
“list_dataset_new”,
which iterates through
the ”images” and
“Masks” folder.
▪ This function also,
imports all the images
in the Jupyter
Notebook and returns
prompt
“Found Train Images”
when the import is
successful

62
Since the Image can be considered
unstructured data, we need to convert it
into a structured format.

63
Converting Image Data to Binary structured data

▪ Building supporting
functions to convert
the ”images” to store
in binary structured
format know as
”tfrecords”.

▪ This format is
compatible with
TensorFlow library

64
Finally, loading the dataset

▪ Building supporting
functions to convert
the ”images” to store
in binary structured
format know as
”tfrecords”.

▪ This format is
compatible with
TensorFlow library

65
Finally, loading the dataset

▪ Converting the images


to NumPy array

▪ Understanding the
dimensions of the
NumPy array

66
Data Exploration
1. Problem Scoping

2. Data Acquisition

3. Data Exploration

4. Modeling

5. Evaluation and Deployment


Let’s explore the dataset !

68
Viewing NumPy array as images

▪ This code helps us to


visualise the numpy
array into colored RBG
images

▪ Pairs of Original
Satellite images and
RGB segmented masks

69
Color coding of the masks

The mask is color coded as follows:

▪ The area in green color


represents
Forest

▪ Area in red color represents


Deforestation

▪ Area in blue color represents


Others(Roads, buildings, etc.)

70
Visualizing Class Distribution

▪ This visualisation helps


us understand the class
distribution between
the classes-
Forest(Green),
Deforestation(Red) and
Others(Blue)

71
Visualizing Merged Images

▪ This visualisation helps


us understand the
accuracy of the masked
images.

▪ We can observe that


the classes of the
original image and the
masked image overlap
accurately. Hence we
can conclude that this
dataset is fit for
training.

72
Visualizing average percentage of area per image

▪ This visualisation helps


us understand the
percentage of area
distributed per image.

▪ We can observe that


majority of the images
in the dataset have at
least 77% area covered
by forest.

73
Modeling
1. Problem Scoping

2. Data Acquisition

3. Data Exploration

4. Modeling

5. Evaluation and Deployment


Building Custom Convolution Neural Network

▪ We build a function to create a block of 2


Layers of CNN.
▪ Building a function helps us to easily change
the parameters like sublayers , batch
normalisation, kernel size and filter.
▪ We use Relu as a activation function.

75
Transpose CNN

▪ Building a function for Transpose Convolution.


▪ CNN usually results in decreasing the
resolution of the original image, as a result
the image segmentation would not match the
same quality as input image
▪ Hence transpose CNN helps in restoring the
original quality of image

76
Building U-Net

▪ Building a function U-net.


▪ U-Nets were originally built
for image segmentation
purposes in medical industry.
▪ U-nets can be built by
manipulating layers of CNNs.

Please view the entire code for U-Net function in the notebook

77
U-Nets were first used for medical image
segmentation!

78
U-Net Application

Original Image U-Net Architecture Segmented Image

79
U-Net Architecture

You can learn more about U- Nets


using the following link :
[Link]
on/guide/how-unet-works/

Olaf Ronneberger, Philipp Fischer, Thomas Brox. U-Net: Convolutional Networks for Biomedical Image Segmentation. (2022). 11 September 2022, from [Link]

80
Loading Pretrained Weights

▪ Training a U-Net model from scratch can be a compute heavy task for
computer and hence that can take a lot of time.
▪ Hence, we use Pretrained Weights from a previously trained U-Net
model
▪ This serves as initial weights for the U-Net models

81
Visualizing Model Summary

▪ [Link](), helps us visualise different layers of our model


▪ We can also view a summary of total number of parameters/neurons
are present in the bottom of the output
▪ In this model, there are 124 Million Trainable Parameters/Neurons

82
Evaluation and
Deployment
1. Problem Scoping

2. Data Acquisition

3. Data Exploration

4. Modeling

5. Evaluation and Deployment


As we are using pre-trained weights, we
don’t have to worry about selecting the
best model.

84
The selected pre-trained weights already
belong to the best model.

85
Hence, we don’t evaluate the model but
evaluate the results, as the outputs are
very visual.

86
Loading test images

▪ Loading all the test images and storing them in respective variables

87
Loading test images

▪ Converting loaded in numpy arrays, because computer can only read


numbers and not images.

88
Loading test images

▪ Predicting the masked images , using the model_1 built earlier

89
Results Image 1

Image 2

90
Quiz time

Let’s Kahoot!

▪ Time to take a short and simple, fun quiz to see


how much have we learnt!

▪ Open Kahoot! App or join at [Link]

▪ Enter Game PIN to start the quiz!

▪ Let’s go!

91
Key Takeaways
1. We explored the impact of global warming on the planet and a few of the
causes of global warming.
2. We understood the importance of Carbon dioxide sinks, hence concluded that
trees are significant in reducing global warming.
3. We built an end-to-end solution to detect deforestation using the U-Net model
by applying image segmentation.

92
Reflection

• How do you think the governments can utilize CNN models built in this module
to regulate/monitor deforestation?
• What are some other methods to control deforestation?

93
Bibliography
▪ What the numbers tells us about a catastrophic year of wildfires. (2022). Retrieved 5 September 2022, from
[Link]
▪ By Katelyn Weisbrod. Global Wildfire Activity to Surge in Coming Years. (2022). Retrieved 5 September 2022, from
[Link]
▪ Turkey wildfires death toll rises to eight. (2022). Retrieved 5 September 2022, from [Link]
europe/news/turkey-wildfires-death-toll-rises-to-eight/
▪ 2021 Turkey wildfires. (2022). Retrieved 5 September 2022, from
[Link]
▪ Here’s what California’s wildfires look like from space. (2022). Retrieved 5 September 2022, from
[Link]
▪ Germany's deadly floods were up to 9 times more likely because of climate change, study estimates. (2022). Retrieved 5 September
2022, from [Link]
▪ 2021 Disasters in numbers. (2022). Retrieved 11 September 2022, from [Link]
▪ Australian Residents Return Home After Flash Floods, Amid Warnings Of Another Storm. (2022). Retrieved 11 September 2022, from
[Link]
▪ Global Ice Viewer. (2022). Retrieved 11 September 2022, from [Link]
▪ Wildfires in 2021. (2022). Retrieved 5 September 2022, from [Link]
▪ 80 large fires have consumed more than 1 million acres across western parts of the US. (2022). Retrieved 11 September 2022, from
[Link]
▪ Average CO2 emissions from newly registered motor vehicles in Europe. (2022). Retrieved 5 September 2022, from
[Link]
▪ How U-net works?. (2022). Retrieved 11 September 2022, from [Link]
▪ Olaf Ronneberger, Philipp Fischer, Thomas Brox. U-Net: Convolutional Networks for Biomedical Image Segmentation. (2022). 11
September 2022, from [Link]

94

You might also like