Skip to content

Authors: Valentin Cojocaru, Data Science Lead, Matthew Gela, Senior Data Scientist, Christelle Xu, Machine Learning Strategy Lead

AI and Machine Learning have rapidly evolved to become an integral part of our daily lives, and are being increasingly integrated into business processes to unlock value. With that, there is an increased necessity to ensure AI is developed equitably, securely, transparently and accurately. In particular, the recent wave of releases of models such as Bard and DALL-E to the public has undoubtedly brought an increased level of opportunity, but also an unprecedented spotlight on the use and misuse of AI.

The UK Government’s new whitepaper on AI Regulation illustrates the importance of integrating Responsible AI into your AI systems. In the age of Generative AI, Responsible AI is more important than ever, and it is crucial for businesses to understand what it actually is. In this first blog of our Responsible AI series, we’ll discuss the context for Responsible AI, why it matters and what it means to develop AI systems responsibly.

Why Responsible AI Matters

“Technology is neither good nor bad; nor is it neutral.” – Melvin Kranzberg

Our society has developed an unconscious trust in technology and engineering, largely focusing on the boundless upside of technological advancement, while at the same time trusting that these technologies are built safely and fairly; we don’t commute to work fearing our trains might suddenly crash. The same mindset has been applied in the field of AI, and over the last decade, many organisations have rushed to create and invest in Machine Learning teams that focus on delivering business value as quickly as possible, often misunderstanding the implications of ML systems that are built with outcomes, and not processes in mind. We don’t need to dig far to see examples of this, including some very high-profile ones.

The good news is that Machine Learning as both a topic and industry solution has become widely adopted, and now industries, governments and the public have started to understand the nuances and implications of building AI systems. Guidelines and principles have been made available by bodies such as the ICO, providing organisations with standards in which to develop AI systems.

Increasing Regulations

Governmental bodies have proposed, and in some cases already created, sweeping legislation to both control the misuse of AI and instil greater transparency in building and monitoring AI systems in production. Early preparation and adoption of the requirements of these policies should be incentivised and enforced sooner rather than later, especially for companies that have built a large number of ML applications in their portfolio and platforms. Understanding regulations, auditing their ML systems, creating blueprints and frameworks to create responsible ML applications by design and actively enforcing these practices takes time and effort.

For example, the EU is expected to pass the EU AI Act in 2023, constraining the use of ‘high-risk’ ML systems such as some of the systems used in areas such as infrastructure, policing, biometric surveillance, and recruitment. Another key aspect of the legislation is the inclusion of certain requirements when building and monitoring these systems, such as the use of high-quality data, documentation, traceability, transparency, human oversight, accuracy and robustness.

In the US, federal, state and municipal laws already touch on ML applications, such as the Equal Credit Opportunity Act and the Fair Housing Act at a federal level, while at the state level New York, Illinois and Maryland have passed laws to mandate bias audits for automated employment decision tools that use AI to assist in candidate screening. More broadly, the White House has released the Blueprint for an AI Bill of Rights, which provides guidance for companies and individuals to protect them from threats presented by AI. China has also passed a regulation that controls the use of algorithms in online recommendation systems.

Developing AI Systems Can be Risky

Outside of any potential legal implications of not adhering to laws and regulations, there are other, equally important reasons why a company should build and maintain responsible ML systems. Companies should consider the cost of a wrong outcome or decision in their business. Could the system have an impact on the customer lifetime value? Are there any other brand or reputational risks involved? Could the system produce deep harm to end users or the general public? Are there any operational risks involved?

Responsible AI is most critical in systems that involve or affect decisions that impact human well-being, including access to resources or their health. For a company, Responsible AI can act as a differentiator, particularly with customers who choose to do business with organisations that align with their values.

What Does it Mean to Develop AI Responsibly?

The emerging field of ML risk mitigation practices has been coined as Responsible AI. Responsible AI does not have a strict and standardised definition, and we should instead aim to define it as a set of principles that govern the responsible and ethical use of AI, in a way that fairly impacts customers and society as a whole. It is usually comprised of the following five pillars:

Bias + Fairness

Fairness in Machine Learning means ensuring that the decisions and predictions made by a model should not unfairly advantage or disadvantage any particular individual or group in society. All ML models show some level of bias, but significant bias, or bias within high-impact use cases, can cause legal liability or real-world consequences. Systemic bias and statistical bias can lead to differential outcomes and discrimination. This can have serious ramifications in domains such as criminal justice, hiring and lending.

One high-profile example of this is the criminal risk assessment algorithm (COMPAS) used by judges and parole officers to predict the likelihood of reoffending in some US states, which was found to give significantly higher risk scores to people from ethnic minority backgrounds. Since data is tightly coupled to the functionality of ML models, care needs to be taken when collecting and understanding data, as well as selecting features for modelling. Detecting, mitigating and reporting bias in ML models across the modelling pipeline (from checking for data integrity at the time of collection all the way to reporting model results against feature distributions) is crucial.

Explainability

Explainability in AI is the set of processes and methods that allows human users to understand and trust the results and output created by machine learning algorithms.

In order to determine whether your AI system is safe for making decisions or augmenting business processes, it is crucial to understand how it comes to a decision. Without this, you can have situations where the model could be basing its predictions on information it should not be relying on. Explainability enables developers to debug their models, stakeholders to understand whether the AI system is fit for purpose, and end users to qualify whether they can trust the model output.

Activities such as engineering meaningful features, generating explanations for individual model predictions, and setting up systems for tracking and creating thorough documentation of models are all ways to incorporate explainability into AI systems.

Sustainability

Sustainability in AI is the practice of developing and using machine learning models in a way that minimises their environmental impact and promotes long-term societal and economic sustainability. As the use of AI and machine learning grows rapidly, the environmental impact of these technologies becomes more significant.

By adopting sustainable practices, we can ensure that these technologies are used in a way that benefits both society and the planet. Measuring energy consumption allows you to determine whether your energy usage is high, and provides insight into areas where consumption could be reduced. In a previous blog, we looked at how to predict the energy consumption of machine learning models based on the number of CPU operations they require.

Other methods to become more sustainable include reducing the amount of data required for training and deploying models, using models that require fewer resources to train and use, as well as optimising hardware usage by using compute resources more efficiently.

Robustness

Robustness ensures that machine learning systems can be monitored and perform reliably in different scenarios and over time. A robust AI system should be able to generalise well to new or unseen data and be resistant to minor changes in the data distribution. In many domains, such as healthcare and autonomous vehicles, the reliability of machine learning models is crucial. A model that is not robust may make incorrect decisions even when the input data is only slightly different from the training data, leading to undesirable consequences.

To improve robustness, you can set up monitoring and alerting designed to perform checks such as detecting data drift and sending an alert when the drift is high. Additionally, validating that the input data to a model is good quality allows the model to train and predict on clean and consistent datasets, which is a crucial step in improving the robustness of a model. In our Vertex AI Tips & Tricks series, we have discussed how you can implement data validation in your machine learning pipelines using Great Expectations, and how you can set up alerting with Google Cloud Monitoring.

Privacy + Security

Privacy and security in AI refers to the protection of sensitive and confidential data used by machine learning models, and ensuring that the models are secure against adversarial attacks.

Taking privacy-preserving measures is crucial for protecting the personal information that organisations store about individuals, preventing it from being misused or shared without consent. Fortunately, there are techniques that can be implemented to enhance privacy, such as data anonymisation, using privacy-preserving machine learning algorithms, or using a federated learning strategy to allow models to be trained across multiple devices or servers without exchanging data.

Model security prevents unauthorised access to machine learning models, protecting them from theft, modification or misuse. Models may also be susceptible to adversarial attacks, which is where attackers can generate examples that are designed to deceive the model into making incorrect predictions, leading to undesirable consequences. Techniques such as adversarial training and defensive distillation can improve the model’s resistance to adversarial attacks.

Conclusion

As AI becomes more widespread, it is crucial that we consider all five key pillars of Responsible AI. In the upcoming blogs in this series, we will expand on how your development teams can incorporate these pillars within your machine learning workflows, and we will demonstrate how to implement and monitor these within a production pipeline. We’ll also look at the wider picture, and give our take on why we believe Responsible AI is crucial in shaping the story of Generative AI towards something beneficial for society.

P.S. Although very tempting, this blog was not written by generative AI…

Datatonic is Google Cloud’s Machine Learning Partner of the Year with a wealth of experience developing and deploying impactful Machine Learning models and MLOps Platform builds. Need help developing an ML model, or deploying your Machine Learning models fast? 

Have a look at our MLOps 101 webinar, where our experts talk you through how to get started with Machine Learning at scale or get in touch to discuss your ML or MLOps requirements!

Authors: Alex Thomas, Senior Data Scientist and Matt Gela, Senior Data Scientist

In the most recent blog of our Computer Vision series, we showed you how to use Vertex AI’s AutoML to train and deploy an Object Detection model. As powerful and efficient as AutoML is, you may want the flexibility to train and deploy more bespoke models, or tackle a Computer Vision task that isn’t currently covered by AutoML. Fortunately, Vertex AI has you covered here as well, with custom options for training and deploying your models on Google Cloud. 

In this blog, we’ll show you how to train and deploy your own custom Image Segmentation model using Vertex AI. We’ll provide a background on Image Segmentation, and Vertex AI’s training options. Then, we will walk you through the step-by-step process of getting your own model up and running.

 

Background

Image Segmentation

Image Segmentation is a technique used in digital image processing, where an image is partitioned into multiple different segments, each representing a different part of the image. Image Segmentation can be used for tasks like distinguishing the background from the foreground in an image, or clustering pixels in an image together based on colour similarities.

In particular, we are going to focus on building a model that can perform a particular type of Image Segmentation, called Semantic Segmentation. 

Semantic Segmentation

Semantic Segmentation is a type of Image Segmentation where the aim is to partition the image into semantically meaningful classes and to classify each pixel into one of these predetermined classes.

Semantic Segmentation is one step more sophisticated than Object Detection, in that rather than trying to draw a bounding box around the object, the goal is to draw a careful outline around the object that is detected so that you know exactly which pixels belong to the object and which pixels don’t.

 

Fig 1: An example of Semantic Segmentation

One important thing to note is that in Semantic Segmentation we don’t differentiate between instances of the same object. For example, if there are two bikes in an image, Semantic Segmentation would label all of the pixels corresponding to either bike with the same “bike” label. This is in contrast to Instance Segmentation, which gives a unique label to every instance of a particular object in the image.

Semantic Segmentation is particularly useful in applications such as self-driving cars, where the car needs to understand exactly which pixels represent a drivable surface and hence where it is safe to drive. Additionally, it can be used in medical imaging to segment sections of the patient’s anatomy, which can make it easier to spot irregularities and diagnose serious diseases.

U-Net

In this blog, the model architecture that we will be using is a special type of Convolutional Neural Network, called a U-Net. U-Net was initially developed for biomedical Image Segmentation, but the architecture is useful in many other applications, making it one of the most important and foundational neural network architectures of Computer Vision today.

To train and deploy such a model on Google Cloud, we’ll need to use Vertex AI’s custom training options.

Custom Model Training with Vertex AI

Vertex AI’s training options allow you to have more control over the model’s architecture, meaning you can train and deploy model architectures that you write yourself. It does this through the use of containers, where you can choose from either pre-built containers (available for supported frameworks such as Tensorflow), or custom container options which allow you to put your code in a Docker container and push it to the Container registry to run on Vertex AI. 

This means that you can deploy pretty much any model framework or architecture you want with relative ease, and can even accelerate the training process using GPUs. Let’s get started!

 

Tutorial

In this tutorial, we train and deploy a model which provides a Semantic Segmentation of urban street scene images. We will use the Cityscapes dataset for this tutorial, where the objective is to label each pixel in the image as one of the following eight categories listed under ‘Group’ in the table below:

 

Fig 2: Categories in the Cityscapes dataset

 

Creating a Project on GCP

To get started in training a custom Image Segmentation model on Google Cloud, create a Google Cloud project and set up a Google account with sufficient permissions. For this tutorial, you will need permission to use Vertex AI and to create and manage Storage Buckets. You may also need to enable certain APIs such as the Vertex AI API, the Compute Engine API, and the Cloud Storage API.

Next, choose a region to run your project in. If you would like to use a GPU to train your model, make sure to choose a region where they are available as they cannot be used in all regions.

Finally, create a cloud storage bucket. This is the location on Google Cloud where all input and output data will be stored.

 

Preparing the Training Dataset

To download and use the Cityscapes data, you will need to sign up for an account and request access. Download the leftImg8bit_trainvaltest.zip and gtFine_trainvaltest.zip files once you have access. Decompress these two files and upload the resulting folders to the base of your Cloud Storage Bucket.

 

Training a Model

The first step in training a model using Vertex AI custom training is to write a Python training script. For this tutorial, we have adapted this script for use with the Cityscapes dataset. Our updated version of this script, named model.py, can be found here.

The first part of this script (see here) is a helper class which makes it easier to read in batches of the training images and their labels, known as segmentation masks, from the Cloud Storage Bucket. Each of these segmentation masks is a 1-D array, which has the same size as its corresponding image, where each entry relates to a pixel in the original image. 

The values for each pixel contain a numeric ID which maps to one of the classes in the dataset. For example, if a pixel in the segmentation mask has a value of 11, that means that the pixel is assigned to that of a building.

Note that instead of training using these classes directly we instead group them into the 8 broad categories mentioned above (flat, human, vehicle, construction, object, nature, sky, void). The id_to_cat variable is used to do this.

Finally, we define the part of the script (see here) which uses our helper classes to load in our training data from our storage bucket, create a model using the get_model method above, train a model, and save it to the storage bucket.

 

Packaging the Model Code to Run Vertex AI Training

The next step is to package up the training code as a Docker container that can be run by the Vertex AI training service. There are two main ways this can be done. One is to create our own custom docker container which packages all of the dependencies and training code together. 

The other, which we use in this tutorial, is to make use of Google’s pre-built training containers. These pre-built containers are a great option if you are training a model which uses one of the common Python libraries for Machine Learning, such as scikit-learn, TensorFlow, PyTorch, or XGBoost. Given the model in this tutorial uses the TensorFlow framework, we use a TensorFlow image here. Select the image you wish to use and make a note of its URI.

At the same time, we also select a pre-built prediction container image that will be used later when deploying our trained model to a Vertex AI Endpoint. Here, again, we use a TensorFlow image. Select the image you wish to use and make a note of its URI.

We can also use GPUs to train the model. Make sure you check your chosen GCP region has GPUs available before deciding to use them.

If your region doesn’t have them available, or you do not want to use them, set the accelerator_type variable in the scripts below to “ACCELERATOR_TYPE_UNSPECIFIED” and make sure the training and prediction container images you select are for the CPU version of the particular framework you are using. Otherwise, select the GPU you wish to use and make a note of its name. For this tutorial, we use a single NVIDIA Tesla K80 GPU.

To make use of the pre-built training containers, we use the Vertex AI SDK for Python (aiplatform) to write a script that automatically packages up the training code with a pre-built training container and runs it on Vertex AI. You can find this script, named train.py, here. We need to update the following variables in the script before running it:

the name of our GCP project (project_id),

the GCP region we’re using (region), 

our GCS Bucket in the same region (bucket_name), 

the URI of our pre-built training container image (train_image), 

the URI of our pre-built prediction container image (deploy_image), 

the type of GPU we want to use (accelerator_type), and 

the path to our training script (script_path)

When the script has run successfully, this should start a training job on Vertex AI.

Once your training job is running, you should see a new entry appear in the Training section of the Vertex AI UI.

 

Fig 3: The Training section of the Vertex AI UI.

You can click into your training job, select its associated CustomJob, and then select View Logs to view the logs produced as your model trains.

 

Fig 4: Logs Explorer in Vertex AI 

 

Deploying Your Model on Vertex AI

Wait until your model has finished training, then click again on its training job entry in the Vertex AI. This will take you to the entry for your model artifact in the Model Registry. Click on Version Details here and make a note of your model’s ID.

 

Fig 5: The Model Registry

Once again we make use of the Vertex AI Python SDK to deploy the trained model to a Vertex AI Endpoint. To do this we need to supply the deploy.py script with the project_id, region, bucket_name and accelerator_type variables, and also provide the model’s ID (model_id).

Once your model has been deployed, you should see an entry appear in the Endpoints section of the Vertex AI UI for your model. Make a note of the ID of this endpoint, as we will need it when using the model to make predictions.

 

Fig 6: Vertex AI Endpoints

 

Using Your Deployed Model to Segment an Image

We will now use our model to segment a test image. The predict.py script takes the image, converts it to a numpy array and sends it to the endpoint. The deployed model returns a segmentation mask which is colourised and saved as a PNG (mask.png) using the Pillow Python library. After this, the script overlays the segmentation mask onto the test image and also saves this overlay as a separate PNG (overlay.png).

Remember to update the project_id, region, and bucket_name variables, and provide the path to the test image (image_path)and also the ID of the deployed endpoint (endpoint_id) in the script below. Then, run it to test your deployed model.

 

Results

Finally, we can examine the two output images to see how well the model performed at segmenting the test image.

 

Fig 7: The original image used in our Semantic Segmentation example

 

Fig 8: The segmentation mask

 

Fig 9: The segmentation mask overlaid on the original image

As you can see, in this case, the model has successfully segmented the image into its component parts. The cars parked on the street (pink) are separated from the trees (green) and buildings (red) surrounding them. The bonnet of the driving car (white) is separated from the road (grey), and the sky (blue) is separated from the trees (green). 

The full list of colour mappings is as follows:

Fig 10: The list of colour mappings

It is worth acknowledging that the boundaries of the masks here are a bit fuzzy; this is because we are shrinking all of our images to 160×160 pixels during training and prediction to simplify the training process. If you want to improve on these results, feel free to try reducing the amount of shrinkage as this may help to make the boundaries between objects sharper. Additionally, we advise experimenting with training the model for a greater number of epochs (defined in train.py), as this should give better results.

 

Summary

In this article, we’ve shown you how you use Vertex AI to train and deploy a custom Image Segmentation model. Hopefully, by now you’ve realised how easy it is to train and deploy your model using Vertex AI once you have developed it. Although the focus of this blog was on Image Segmentation, you can use the same training and deployment methods via the Vertex AI Python SDK for a much larger range of Machine Learning tasks.

The scripts we’ve provided in this blog are easily adaptable, with very few modifications needed to be made to the train.py and deploy.py scripts in particular, so we hope you enjoy tweaking them for your own use case!

Author: Ruairidh Russell, Machine Learning Engineer

In the first and second parts of this Computer Vision blog series, we spoke with some of Datatonic’s experts to hear their experiences of Computer Vision, and where it is heading in the next few years. This blog will provide a step-by-step walkthrough of how to develop your own Computer Vision model, train it on Google Cloud, and deploy it without writing a single line of code courtesy of Vertex AI’s AutoML service.

Introducing AutoML on Vertex AI

One of the key trends in Machine Learning in 2022 is no-code AI: an efficient method to get started on AI projects with minimal effort or domain knowledge. The Vertex AI AutoML service is an example of this trend and allows developers, software engineers, or just curious minds to train efficient, high-quality Machine Learning models effortlessly. 

AutoML caters to a wide range of applications, which includes extracting insights from tabular, language, and image data. The service is well suited to rapid experimentation during the early stages of a project, developing proof of concepts, and even building high-performance models to serve both online and offline (Edge).

Object Detection

In Object Detection, our goal is to locate instances of desired objects within images. For those of you with more of a Machine Learning background, the task can be thought of as both classification and regression; the network uses a classification head for predicting the class type and the regression head of the network is used for optimising the bounding box location. To put it simply, we are training a model to draw boxes around desired objects in an image. 

 

Object Detection being used to monitor traffic
Fig 1: Object Detection being used to monitor traffic

Object Detection has many applications that can help automate processes in various industries. Examples include locating faults within parts on a production line or monitoring the types of traffic on certain roads. In this walkthrough, we build a Datatonic Logo Detector, where the objective is to locate and draw boxes around every instance of the Datatonic logo within an image.

 

Creating a Vertex AI Managed Dataset

Within Google Cloud head over to Vertex AI (found within the navigation menu on the left-hand side of the User Interface), and navigate to the “Datasets” section to begin your project. Select “CREATE” and follow the steps to set up your dataset of choice; in this case, “Image object detection”. 

 

Selecting Image object detection on Vertex AI
Fig 2: Creating a managed dataset on Vertex AI

Next, we will need to import our image data. From within your dataset, navigate to the “IMPORT” tab and choose the “Upload images from your computer” option, and select your data for upload. In this example, we are going to define our Training, Validation, and Test sets via the User Interface (UI), so leave “Data split” as “Default” when importing. The images will be uploaded to Google Cloud Storage so you must also specify a Cloud Storage bucket for them to be stored.

 

Adding images to your Vertex AI dataset.
Fig 3: Adding images to your Vertex AI dataset

 

Data Labelling

Once your dataset has been uploaded, it is time to start the data labelling process. This is where we tell the Object Detection algorithm what to learn by drawing boxes around the desired objects and classifying them. Each group of objects we would like to detect, such as cats or dogs, are called classes. In this case, bounding boxes are drawn around only a single class: the Datatonic logo. However, it is possible to label and classify multiple classes.

Navigate to the “BROWSE” tab and under “Images” select “ADD NEW LABEL” and add a label for each class you would like to train on. Ideally, we should have an equal number of examples of each class within the dataset to give AutoML the best chance to perform well across your data; this is called balancing the classes. 

 

Labelling data for the Object Detection model
Fig 4: Labelling data for the Object Detection model

To label your data, select an image in your Vertex AI Dataset and then click on “Add bounding box” in the toolbar above your image. Simply click to draw your bounding boxes around the desired objects – all occurrences if there is more than one in an image. Draw these bounding boxes as tightly as possible around the perimeter of the objects; this reduces unnecessary noise and helps the algorithm to learn your objects better.

After drawing each bounding box, you will be prompted to confirm which class the objects belong to. Follow this procedure until all of your data is fully labelled. The labelling service provided by Vertex AI’s managed datasets is another key advantage to using Google Cloud as this avoids the difficulties associated with using external labelling software. 

If you have a lot of images to label, you can also take advantage of another Vertex AI service and let others label the images for you. Simply navigate to “CREATE LABELING TASK” to specify your labelling instructions, but bear in mind this will incur additional charges. 

 

Object Detection Model Training

Typically, one of the most time-consuming aspects of a Machine Learning project is model development, where it can take many weeks to experiment with different modelling approaches and custom algorithms to find the optimal solution. 

With Vertex AI’s AutoML, users do not need to spend time on model selection, experimentation, or hyperparameter tuning; this is all taken care of, allowing for more time to be spent on other areas, such as data collection or building the infrastructure around productionising your solution. 

Users are also not limited by the constraints of their local machines, which often affect the algorithms chosen and training time; Vertex AI will handle the compute resources used for training your complex models.

To commence training, select “Train new model” from the panel on the right-hand side of the UI, and within “Training method” select “AutoML”. 

 

Defining training, validation, and test data splits.
Fig 5: Defining training, validation, and test data splits

For AutoML to train on your data, it needs three dataset splits: training data (used during training), validation data (used to monitor training), and test data (used for testing after the model has trained). 

In terms of splitting your data into these sets, there are several options:

  1. Allow Vertex AI to do this randomly for you, where you only need to determine the split percentages (the default is 80% Train, 10% Validation, and 10% Test).
  2. Manually select images for each set via the UI (use the “ASSIGN ML USE” option). 
  3. Specify within the image import JSONL file.

Using the default splits that AutoML generates for you is the easiest and quickest method and reduces the complexity of your project. If you choose to manually select which images are present in your training, validation, and test sets, then it is advised to keep the splits similar to the defaults, and ensure that each set has equal proportions of each class. 

By selecting the “Randomly assigned” option within “Model details”, the splits are taken care of for you so you can jump straight into training (Fig 5).

Despite taking care of model training and selection for you, Vertex AI’s AutoML allows for the specification of certain model characteristics to suit your use case. In addition to allowing for online and offline model serving, you can specify whether to optimise for accuracy or low latency under “Training options”. This gives control to the user to mould the AutoML model to the project requirements or business needs. 

 

Selecting your training options
Fig 6: Selecting your training options

For “Compute and pricing”, it is important to be aware of the costs associated with using Vertex AI’s AutoML service. A useful tip for when you submit your training job is to ensure “Enable early stopping” is selected (Fig 7). This means that when the model has converged (essentially meaning it will not learn anymore from the data provided) training will stop, and you will only be charged for node hours used instead of the full budget allocated. 

When ready, select “START TRAINING” and you can now relax without the need to monitor live model metrics, as this is also taken care of for you.

 

Vertex AI AutoML Train new model screen with compute budget settings
Fig 7: Selecting the training length and pricing options

 

Model Evaluation

Once training is complete (the status of this can be found under Vertex AI “Training”), you can then navigate to the “Models” page to analyse its performance by simply selecting your model and version. The “EVALUATE” tab allows you to see key metrics relating to your model’s performance such as precision, recall, and average precision as well as providing you with various graphs which allow you to gain a deeper understanding of your model. 

 

Vertex AI model evaluation showing precision and recall metrics
Fig 8: Evaluating the model performance

To observe a more detailed, object-by-object analysis, select a class beneath the “All labels” section. The UI shows how your model is performing on your test images by displaying your True Positives, False Positives, and False Negatives. This means you can see which images your model performs well on, and where it could improve, allowing for data-driven decisions to be made for improving performance. 

For example, is there a particular type of class or image angle that is not performing so well? If so, you can tailor your dataset to include more images of these occurrences. Even without Machine Learning expertise, it is straightforward to understand how your model is behaving via this evaluation service. 

There are also some slightly more technical aspects of the service; you can alter the confidence and IOU thresholds that are used when calculating whether an instance is a True Positive, False Positive, or False Negative, and thus visualise how these thresholds are affecting your results. You can also alter the desired confidence threshold when serving your model based on whether you wish to prioritise precision or recall.

 

Labelled training images for object detection in Vertex AI
Fig 9: True Positives, False Positives, and False Negatives of the Datatonic Logo class

 

Model Deployment

Once you are happy with your model, it is time to deploy and see it in action! Navigate to the “DEPLOY & TEST” tab and follow the instructions to create your endpoint. This will deploy your model to Google Cloud. 

With AutoML Edge, you are also able to export your model as a TensorFlow Lite model, a TensorFlow SavedModel to run in a docker container, or as a TensorFlow.js package for running in a browser. This flexibility in deployment methods is another reason why this service is so beneficial to so many users. 

Once you have deployed your model to an endpoint, you can test it by uploading images to the UI to see it in action! As we can see in Fig 10, the model has predicted many bounding boxes for the image. On the right-hand side, we can see the confidence of the predictions, and ignore the low ones. If you hover your cursor over the predictions, then the bounding box they relate to is highlighted. In this case, it successfully classified the three logos! Remember to undeploy your model from the endpoint when you are finished.

 

Vertex AI object detection test showing bounding boxes on an image
Fig 10: Deployed model predictions

 

Diving Deeper into Object Detection and AutoML

So far, we have discussed the no-code, no-ML-expertise-needed approach to AutoML. However, for those of you who are curious to dive deeper into the service to integrate your model into your application then I encourage you to take advantage of Vertex AI’s API. You can use this to train your model, deploy it to an endpoint, call online predictions, make batch predictions on a set of data, and to further evaluate your model’s performance with metrics such as the F1 score.

 

Summary

With Vertex AI’s AutoML service, Machine Learning has become much more accessible and democratised for users with little prior expertise in the area. The quality of no-code Machine Learning solutions is only going to get better over the next few years and the high performant and easy-to-productionise nature of Vertex AI’s AutoML means that the service can allow for the fast integration of AI into businesses to rapidly generate real value.

As 4x Google Cloud Partner of the Year, Datatonic has a wealth of experience in Computer Vision, Machine Learning, and a range of Google products and services. Contact us here to discuss how using Object Detection or other Machine Learning models could help your business! 

 

Check out our other Computer Vision blogs in this series:

Part 1: Computer Vision: Insights from Datatonic’s Experts

Part 2: Computer Vision: Emerging Trends and Google Cloud Technology

Part 3: Computer Vision: Object Detection and No-Code AI with AutoML

Part 4: Computer Vision: Deploying Image Segmentation Models on Vertex AI

Part 5: Computer Vision: Generative Models and Conditional Image Synthesis

How to Forecast Mobile Network Traffic Using Machine Learning

5G technology is a game-changer. It will enable unprecedented high-speed internet on the mobile network. For telecom providers, this new technology represents both a huge business opportunity and a challenge in network operations. The increase in flexibility and in complexity for network operations creates favourable grounds for AI. In this post, we present the work done by Datatonic and Vodafone Group R&D to build traffic forecasting ML models, which is a key stepping stone towards an AI-powered 5G network.

How 5G is a game-changer

5G is here, and it is a game-changer in the telco industry and beyond. 5G technology will deliver mobile high-speed internet, very low latency and allow for seamless connection to a huge amount of devices on networks. This means high-speed internet on the move, for all users – both human and machine… 

For telecom providers, 5G technology offers both great opportunities and great challenges to deliver a service that exceeds customers expectations. In terms of opportunities, 5G will unlock value across a wide range of new use cases, beyond current imagination. To mention just a few examples: massive IoT, connected vehicles, and mission-critical health [1,2]. On the other hand, the challenges are to leverage the flexibility of 5G virtual radio and core networks, while managing the complexity brought by the predicted huge amount of devices and the mix of physical and virtual network assets. Operating and optimising such complex networks becomes a superhuman task, and this is where AI becomes a critical part of 5G.

Vodafone has embraced the opportunities presented by 5G and telco digital transformation: 1. Next-generation network infrastructure, 2. Open digital architecture [3], 3. Big Data & AI and 4. Cloud technology.

Such pillars can eventually drive a transformation in business objectives:

  • Deepening customer engagement: customer centric operations and highest quality of service on the networks will lead to high customer satisfaction and high retention
  • Efficient and autonomous networks: the software based 5G network, powered by AI, will reduce the effort required to operate the network, prevent issues, reduce time to detect and fix anomalies, and improve assets utilisation, overall reducing operation costs
  • Growing offerings in B2B and B2C: network virtualisation and massive IoT connectivity will unlock new services and business models, and unlock new revenues.

“Companies like Vodafone are already unleashing the power of Big Data, Analytics and Cloud in many areas. However, much more is to come. It will make us more customer-centric and the business more efficient.” 

– Luke Ibbetson, Director of Vodafone Group R&D.

AI-powered traffic forecasting model

In the context of Vodafone’s introduction of an open digital infrastructure, Datatonic built and delivered an ML solution to forecast internet traffic on a mobile network of a large European city, using anonymised open-source data [4].

The project aimed at the following main objectives: 

  • Assess feasibility to build a unique ML model to forecast traffic on a network of 10,000 locations points,
  • Demonstrate how Google Cloud Technology can accelerate the development of ML solutions,
  • Explore further architectural advances and steps towards the realization of different use cases.

The benefit of using Google Cloud Platform is the power of managed and scalable services to accelerate development. Those services enable data scientists to focus on the essentials when prototyping new ML solutions: the approach and the models, instead of setting up resources and environments. 

The following Google Cloud Platform components were used in our work. The raw historical data was uploaded to Google Cloud Storage, a scalable blob storage component. Dataflow processed and transferred at scale the raw data into BigQuery. BigQuery was used to explore and transform the data using SQL in preparation of ingestion by a ML model. AI Platform notebook provided a scalable, managed Jupyter notebooks service for prototyping ML models using Python and TensorFlow, enabling us to easily switch between CPUs or GPUs depending on the workload. The ML models were trained and served using AI Platform training and prediction, respectively.

Finally, the predictions of the model were stored into BigQuery to enable deeper analysis of predictions and model performance across the network.

Step 1: Data exploration and business insights

We started with a thorough exploration of the data. With unsupervised ML techniques, we can identify various usage patterns across the different locations in the networks. For example, some zones exhibited peaks of traffic just before and just after local business hours, corresponding to workers commuting to and from work. Other zones showed high traffic during local office hours and dropped significantly outside those hours and on the weekends, which identifies regions as business districts. Similar methods help identify regions as residential areas, suburban areas, and nightlife districts. 

Fig. 1. Areas with similar user’s internet activity patterns, and representation of these daily internet activity patterns. The unsupervised machine learning algorithm groups geographic locations together based on similarity between the users’ daily internet traffic patterns. Those groups are called clusters. The map (on the left) shows in a different color the locations belonging to each cluster.  The curves (on the right) represent the different typical internet traffic patterns for each cluster.
Fig. 1. Areas with similar user’s internet activity patterns, and representation of these daily internet activity patterns. The unsupervised machine learning algorithm groups geographic locations together based on similarity between the users’ daily internet traffic patterns. Those groups are called clusters. The map (on the left) shows in a different color the locations belonging to each cluster.  The curves (on the right) represent the different typical internet traffic patterns for each cluster.

Step 2: Development of ML forecasting models 

After identifying areas that exhibit different behavioural patterns of network usage, the next natural task is to address forecasting.

It is good practice to start development by defining a baseline. The baseline will help put the performance of complex machine learning models into context. We decided to use a persistence model, also called naive forecast. The persistence model consists of using the value at the previous time step to predict the value at the next time step. The persistence model is often used as a baseline in time series forecasting: it is simple to implement, fast to infer predictions and performs well as a first approximation.

An extensive comparison of the model performances for our use case is not straightforward, because of the spatial and temporal dimensions in the particular data. The errors for each model were calculated using the predictions over a test set representing one week of unseen data and over the whole network. For simplicity, we decided to reduce the performance of a model into two values: the average (over one week, and over 10,000 locations) of the mean absolute error (MAE), and the average of the mean squared error (MSE).

The first model built was a MultiLayer Perceptron neural network. This approach relies on data scientists to engineer features to capture specific insights observed in the data and to feed these features directly as input to the model. Time series tend to have seasonality (monthly, weekly, daily patterns) which, if captured in features, will help with the model performance. We thus engineered features related to the date (day of the week) and time (hour of the day) and created embeddings for these features. Then we created lag features: we used the historical values for the target variable (internet usage) three hours before the prediction time, one day before, and one week before. Finally, we defined a categorical feature to represent each location in the network. Leveraging those features, the trained model predicts the internet usage at the location in the network and the time of the day defined by the input features.

The second model we explored was a densenet neural network [5]. The approach, in this case, is to consider the network as an “image” and try to predict how the next frame (i.e. the values at each node of the network in 1 hour) will look. With this approach, the only inputs are some sequences of network internet usage. The data scientists rely entirely on the model to find hidden patterns in the data and are not required to create features (which can introduce insights as well as bias) to feed to the model.

Both approaches led to similar performance, and they both exhibited significant improvement compared to standard time series forecasting baseline methods (we observed a 25% decrease of mean absolute error compared to the naive persistence model). They also reach similar performance as SARIMA, a well known statistical method for time series forecasting. However, the benefit of the model we implemented over SARIMA is scalability: our single model generates predictions for all of the 10,000 locations, whereas using SARIMA requires one model for each location (i.e. 10,000 models to cover the whole network !).

Heatmap of internet traffic across the city: predictions (on the left) versus recorded (on the right) internet traffic.
Fig. 2. Heatmap of internet traffic across the city: predictions (on the left) versus recorded (on the right) internet traffic.

Step 3: Leverage ML model insights to take actions

Beyond model performance considerations, it is important to realise that the prediction of the internet traffic on the network, as provided by our model, is not an end in itself, but rather a key stepping stone to leverage 5G technology. It is crucial to define the use cases that those predictions will support, and the impact and value that will result from it. In other words, traffic prediction does not have a business impact on its own. It is how you take action on these predictions that will define the impact and the value for your business.

“The telecoms industry is envisaging impact in multiple areas, including closed loop network automation. This is not an easy feat to achieve: from network telemetry data to predictions to automated decision making concerning how to adjust the right knobs in the network. Once this works, it will be magic.”

– says Guenter Klas who is leading the AI Research Cluster in Vodafone Group R&D. 

“Working closely with the experts from Datatonic, we have been able to achieve our targets very fast and as desired.”

The goal for the traffic forecasting solution is to use AI to enable optimal provisioning of resources on the network at a large scale and thus minimise operation costs and energy consumption for a complex network. For this specific use case, the prediction of the model will be used to suggest when network resources (e.g. for required bandwidth) should be upscaled or downscaled, in order to find the right balance between providing to customers excellent access to their services without lags or delay in access, and avoiding wasting operational resources by providing much more network capacity than needed.

While this solution initially aims at becoming an assistant for human decision making, the next step is to leverage this solution to deliver the insights to a second layer that will automate making the decisions on how much to up/downscale or otherwise adjust resources according to the forecasting prediction. Those solutions will enable a transition into closed loop zero-touch network operation, where humans monitor the solutions with minimal required interventions.

Conclusion

Datatonic and Vodafone developed a 100% Google Cloud-native set of ML models for cellular internet traffic forecasting. This AI-enabled traffic forecasting capability is the beginning of the journey to closed-loop autonomous operation. One step at a time, this path will lead to automated, highly optimised network operations, where humans can rely on AI to assist them in running incredibly complex systems, and it helps Vodafone “connect for a better future”. The Humans will then have more time available to create new services, new business models, new ecosystems, … to make the most of the new technology and to offer new and unique customer experiences, beyond our current imagination.

 

[1] https://www.nokia.com/networks/5g/use-cases/
[2] https://www.ericsson.com/en/5g/5g-for-business
[3] https://www.tmforum.org/oda/
[4] The Telecom Italia Big Data Challenge, Link to dataset
[5] Citywide Cellular Traffic Prediction Based on a Hybrid Spatiotemporal Network