You are on page 1of 8

OFFICIAL (CLOSED) \ NON-SENSITIVE

Machine Learning Workflow


In his lesson, you will be involved in 5 stages of the machine learning workflow:
1. Collect data
2. Prepare Data
3. Train
4. Evaluate
5. Deploy

4
OFFICIAL (CLOSED) \ NON-SENSITIVE

Collect Data
• There are many ways to gather the dataset you need, one of the ways is to search
for them using Google.
• Install the Chrome extension to download the images easily
• You may want to find out how to download the images using code as well at
https://pypi.org/project/bing-image-downloader/

5
OFFICIAL (CLOSED) \ NON-SENSITIVE

Prepare Data – Clean Data


• One of the tasks in data preparation is to make sure the images are of the
suitable format.
• imghdr is a module that we can use to test the images to see if they are of
the format Tensorflow can use to train.
• In our case, we change the extension to .to_delete for the files that are
tested unsuitable so we can delete them

6
OFFICIAL (CLOSED) \ NON-SENSITIVE

Prepare Data – Clean Data

Look into all the subfolders and files

Test the file

7
OFFICIAL (CLOSED) \ NON-SENSITIVE

Prepare Data – Split into Train and Test Data

Look in the ‘images’ folder and assign the images to


the class name of the enclosing folder name
subset=‘training’ creates the training dataset

subset=‘validation’ creates the validation (test) dataset

8
OFFICIAL (CLOSED) \ NON-SENSITIVE

Prepare Data - Normalization

Function to divide all pixel values by 255 to


compress the values to a range between 0 and 1

Apply yhe function on the datasets

9
OFFICIAL (CLOSED) \ NON-SENSITIVE

Deploy
• We use gradio to easily put up the user interface to let use drop the
images to test.

Take in the image

Reshape the image to the same as the training image

gradio needs this as output

10
OFFICIAL (CLOSED) \ NON-SENSITIVE

Deploy

Create a gradio UI that lets user select an image and


send to the classify_image function

The classify_image function returns and is used by


gradio to display the result

You might also like