Baby step by step approach to using Google Cloud AutoML Vision to Create a dirty/balanced binary…



Original Source Here

Baby step by step approach to using Google Cloud AutoML Vision to Create a dirty/balanced binary classifier to detect pneumonia using chest x-rays without writing a single line of code.

We are in a century where every task we carried out on our local machine is now being done on the cloud due to the Flexibility, Reliability, Collaboration, Lower costs related to hardware and software, Data protection and security, Energy saving, those features actually make cloud standout and more preferable to local machine.

In this article I will be giving a baby step by step approach to using Google Cloud AutoML Vision to Create a dirty/balanced binary classifier to detect pneumonia using chest x-rays without writing a single line of code.

Let get started by training a model simply using 100 images from the “normal” class and 100 images from the “pneumonia” class but deliberately create a “dirty” dataset by putting 30 “normal” images in the pneumonia folder and 30 “pneumonia” images in the normal folder

This article will guide you through the process of creating and training a model on Google Cloud’s AutoML Vision platform step by step.

1. Download Kaggle Chest X-Ray Images (Pneumonia) Dataset by clicking on this link https://www.kaggle.com/paultimothymooney/chest-xray-pneumonia#chest_xray.zip.

2. Go to Google AutoML: https://cloud.google.com/automl/.

3. Click “TRY AUTOML” and select “AutoML Vision”.

4. Sign in to Google Developer or create an account.

5. After you log in, head to the AutoML Vision Console: https://console.cloud.google.com/vision and Accept the terms of service.

6. Next create a project with any title.

7. Once on the dashboard click “Get Started” on AutoML Image Classification.

8. Accept all the screens then you will reach the last page where you have to set up billing and Vision API.

9. When you go to billing, you should see an option to activate free $300 credit at the top of the screen. Click “ACTIVATE”

10. Select “Individual” account type and input all necessary info including card. Google does not charge this card unless you manually upgrade to a paid account.

Do not upgrade to a PAID account because your credit card will be charged and if you are using it for a company project that need to be host on cloud, you can upgrade it to a paid account but your card will be charge, bear in mind the following guidelines from the Google Cloud Platform Instructions

1. The free trial ends when you use all of your credit, or after 3 months, whichever happens first.

2. You may also lose your data after the trial period is over. I recommend that you review the full set of guidelines from Google Cloud Platform services.

11.Once you have completed the billing you can go back to the project set up page and click “SET UP NOW” to enable the vision API. This will automatically set up the API and should redirect you to select the Google Cloud Project

12. In the dropdown you should see the project that you created. Select the project and continue.

13. Next, you should see the Datasets page. Click “NEW DATASET” at the top of the page.

14. Select “Single-Label Classification”.

15. Create your dataset.

a. Give the dataset a name.

b. Open the folder of Chest Xrays you downloaded from Kaggle and go into the train folder.

c. In a separate folder create a directory with the following structure:

i. AutoMLDataset/

1. normal/

2. pneumonia/

d. Then copy between 100 images of each type of each classification and deliberately create a “dirty” dataset by putting 30 “normal” images in the pneumonia folder and 30 “pneumonia” images in the normal folder from the original train/ folder (normal, pneumonia) into the appropriate new folder. Once you have your images in the new folders then zip the whole AutoMLDataset/ folder to create automldataset.zip.

16. Now back in the AutoML Console Dataset go ahead and upload the zip file with all the images. Again, make sure you zipped the top-level folder that contains two folders: normal/ and pneumonia/ with the associated sets of 100 images in each folder This will allow AutoML to automatically detect the correct ground truth label for each image by looking at the name of the folder in which it is contained. Once the zip file is attached go ahead and “CREATE DATASET”. For our current labeling scheme, there is no need to select the button to “Enable multi-label classification” (this allows you to apply multiple labels to a single image). This step may take a few minutes to upload all the images and set up the dataset.

17. Once the data is ready you should see a screen with all the images you added as well as a label of “normal” or “pneumonia” under each image. These are the images and ground truth labels that will be used to train/test/validate your pneumonia detector model.

18. Next click on the “TRAIN” tab and here you will see the distribution of images as well as the splits for training, validation, and test images

19. Click “START TRAINING” to begin training your pneumonia classification model. In the options keep all the defaults (Cloud-hosted, 8 node hour) and then start the training.

20. Now the model is in the training phase. Go grab your phone and start playing your favorite game. Once the model training is done you will be notified via email.

21. Once the training is complete you can click on the “EVALUATE” tab and you will see various metrics about the model such as precision, recall, and a confusion matrix. Try to understand what each of these metrics means and how they are calculated.

22. Next click on the “TEST&USE” tab and this is where you can test the model on new data that the model has never seen. If you click “UPLOAD IMAGES” and select an image from the Kaggle dataset that you did NOT use in the training set of images and watch the model predict whether or not the patient in the x-ray has pneumonia or not. Try to find images that produce both correct and wrong predictions.

Waoo!!! Congratulation, you made it. That’s it! You’ve built your first AI model! Now you know how to upload data and train the model on google cloud

AI/ML

Trending AI/ML Article Identified & Digested via Granola by Ramsey Elbasheer; a Machine-Driven RSS Bot

%d bloggers like this: