Google Cloud AutoML Vision for Medical Image Classification
Google Cloud AutoML Vision simplifies the creation of custom vision models for image recognition use-cases. The concepts of neural architecture search and transfer learning are used under the hood to find the best network architecture and the optimal hyperparameter configuration that minimizes the loss function of the model. This article uses Google Cloud AutoML Vision to develop an end-to-end medical image classification model for Pneumonia Detection using Chest X-Ray Images.
The dataset contains:
The dataset is hosted on Kaggle and can be accessed at Chest X-Ray Images (Pneumonia).
(1). Go to the cloud console: https://cloud.google.com/
(2). Open Cloud AutoML Vision by clicking the triple-dash at the top-left corner of the GCP dashboard. Select Vision under the product section for Artificial Intelligence.
(3). Select Image Classification under AutoML Vision.
(4). Setup Project APIs, permissions and Cloud Storage bucket to store the image files for modeling and other assets.
(5). Select your GCP billing project from the drop-down when asked. Now we are ready to create a Dataset for building the custom classification model on AutoML. We will return here after download the raw dataset from Kaggle to Cloud Storage and preparing the data for modeling with AutoML.
In this case, the automatically created bucket is called: gs://ekabasandbox-vcm.
(1). Activate the Cloud shell (in red circle) to launch the ephemeral VM instance to stage the dataset download from Kaggle, unzip it and upload to the storage bucket.
(2). Install the Kaggle command-line interface. This tool will allow us to download datasets from Kaggle. Run the following code:
Note, however, that the Cloud Shell instance is ephemeral and does not persist system-wide changes when the session ends. Also, if a dataset is particularly large, other options exist such as spinning-up a compute VM, downloading the dataset, unzip it and then upload to Cloud Storage. It is possible to design other advanced data pipelines to get data into GCP for analytics/ machine learning.
(4). Download Kaggle API token key that will enable the Kaggle CLI to authenticate/ authorize against Kaggle to download the desired datasets.
(5). Download dataset from Kaggle to Google Cloud Storage.
(6). Unzip the downloaded dataset
(7). Move the dataset from the ephemeral cloud shell instance to the created cloud storage bucket. Insert your bucket name here.
(1). Launch Jupyter Notebooks on the Google Cloud AI Platform.
(2). Create a new Notebook Instance.
(3). Select an instance name and create.
(4). Open JupyterLab
(5). Before building a custom image recognition model with AutoML Cloud Vision, the dataset must be prepared in a particular format, they include:
(6). Clone the preprocessing script from Github. Click on the icon, circled in red and labeled (1) and enter the Github URL https://github.com/dvdbisong/automl-medical-image-classification to clone the repo with the preprocessing code.
(7). Run all the cells in the notebook preprocessing.ipynb
to create the CSV file containing the path and labels of the images and upload this file to Cloud Storage. Be sure to change the parameter for the bucket_name
.
(1). Click on “New Dataset” from the AutoML Vision Dashboard.
(2). Fill-in the dataset name and select the CSV file from the Cloud Storage bucket created by AutoML.
(3). For now, you may dismiss if you see the error message that duplicated files are located. To the best of my knowledge, this is not the case as per the file names.
(4). Click on Train as shown in red in the image above to initiate model building with Cloud AutoML.
(5). Select how the model will be hosted, and the training budget.
(6). After model training is complete, click on Evaluate to view the performance metric of the model.
(7). Assess the performance metric (precision, recall and confusion matrix).
(1). Click on the Predict tab to test the model.
(2). Here’s an example of a test. The image is a chest x-ray scan that was not used to train the model. The medical experts reading this can verify the accuracy of the model prediction.
The custom image recognition model is also exposed as a REST or Python API for integration into software applications as a prediction service for inference.
The article provided a walkthrough to design powerful vision models for custom use-cases by leveraging Google Cloud Platform AutoML Vision. Moreso, the model is hosted on the cloud for inference as a prediction service. This is a powerful mechanism to quickly prototype and build image classification or object detection use-cases before deciding whether to go ahead with more fine-grained and or hand-tuned modeling efforts. With this, I trust it will serve as a template for applying to the vision problems that you care about. Also, be sure to delete your models and datasets when it is no longer needed, this will save cloud costs.
Excerpts of this article are taken from the book “Building Machine Learning and Deep Learning Models on Google Cloud Platform” to be published soon by Apress.
Google Cloud AutoML Vision for Medical Image Classification
Research & References of Google Cloud AutoML Vision for Medical Image Classification|A&C Accounting And Tax Services
Source
0 Comments