Machine learning with OutSystems: Object detection app

By 24 February 2022Blog, Collaborations, Functionality
Machine learning with OutSystems: Object detection app

TL;DR: test the object recognition app here

The adoption and implementation of low-code applications has made application development cheaper and faster, and more accessible to a large audience. OutSystems, one of the market leaders in the industry, seeks innovative collaborations to help their clients deliver more and more value. One of these collaborations is with UbiOps, a Dutch software company that enables data scientists to bring their Python and R scripts to production, scalable, reliable, and secure. According to The Next Web, 9 out of 10 models don’t make it to production (TNW, 2021). Combining OutSystems with UbiOps enables you to create data science-based applications easily.

Advanced analytics + low code

If you want to make an app that interacts with a machine learning model in the background you need to run that model somewhere. Often, however, Python and R code cannot be run within the low-code app development environment and you’re prone to look somewhere else. Setting up or even building your serving environment to run your code requires very different (software engineering) skills than what’s needed to develop low-code apps or build data science models. That’s what UbiOps takes care of for you. Using UbiOps in combination with OutSystems, applications to predict churn, detect fraud, recommend products, or any other kind of app that uses analytics is created in a fraction of the time it usually takes.

Object recognition use case

To showcase the proposition we developed a simple mobile app that you can use to detect objects. For this app we needed to create

  1. A UbiOps account;
  2. Deployment package (download here);
  3. An OutSystems account;
  4. The actual app (download here).

The high-level architecture looks like this:

 

 

Deployment of YOLOv4 object recognition model on UbiOps

In the world of object detection, the “you only look once” (YOLO) algorithm is one of the most trusted and proven algorithms. We are not going to explain the inner workings of the algorithm. Instead, we are going to focus on:

  1. How to deploy a pretrained version (YOLOv4) on UbiOps;
  2. How to create a token for that deployment so that we can use it in our OutSystems app.

Step 1: Deploy pretrained version

In order to get an algorithm onto UbiOps you need to do a few things. Most importantly you need to define inputs and outputs and add your algorithm code. Today however we are going to skip it by using a completely premade package which we can import. You can do that by going to the imports/exports menu and then clicking on import.

 

 

You will see a screen similar to the image above. Upload the zip you downloaded earlier and click “next”. After that you can immediately press the confirm button. Everything should be correct. After that you will see a new deployment in your list of deployments. You will have to find the API endpoint of that deployment. You can find it here:

 

It will be in the format of: https://api.ubiops.com/v2.1/projects/<YOUR_PROJECT_NAME>/deployments/yolov4-object-detection

Step 2: Create an authentication Token

We now have the API endpoint, and we can use that in the OutSystems app. But we need something else from UbiOps. We need a secure method of authentication. So that not every app can use our deployment.

Create a new Token by going to the token menu in the permissions section. If you click “add token” you will see something similar to the screenshot below:

 

There will be three steps in creating a token. In the first step for now only the name is required. Skip the rest and press “Next”. In step 2 give the token a role, this will give it access to only the permissions specified in this role. In our case we can fill in the following:

 

Click “assign” and then next. You will now see your token string. Copy this and keep it because you will not be able to get it again.

Take the Token string and the API endpoint and continue with setting up OutSystems.

 

Design of mobile app with OutSystems

To develop the mobile application to capture an image and send it to UbiOps to process its data and return the detected objects, we use OutSystems’ IDE called ServiceStudio. We have to:

  1. Consume the UbiOps end-point;
  2. Create a page to take an image and display the results;
  3. Publish the application.

In ServiceStudio we start by creating a new application from scratch, choose a Phone App as a template and give the app an icon and a name. Based on this the app gets created and common functionality like a splash screen, login functionality, a home page and a look and feel derived from the base colors from the icon is already there.

Step 1: Consume the UbiOps end-point

From there we immediately start consuming the UbiOps REST endpoint for the Yolo4 model. We use the URL provided, select Post for the method as we are going to send a picture, and define the request and response according to UbiOps specifications:

 

In the Headers and Authentication tab we add an Authorization header, so we can provide the security token in the request.

Step 2: Create a page to take an image and display the results

As a blank homepage has already been created, we use this to add the functionality. First we add the Camera Plugin from the Forge, OutSystems library of open source components, and select the TakePicture action. Then we add a camera icon to the page and create the functionality behind it, the so-called ‘handler’. In this handler we are first calling the TakePicture action, then storing the image as a blob, and finally calling the UbiOps Yolo with the identifier of that blob. The output of this service can be used on the page to display the image and a list of the detected objects:

 

Step 3: Publish the application

As a last step we need to Publish our application, so we can start using it. Publishing is as easy as clicking the green button in the top (if it is red, OutSystems has detected that your application still has some errors) and waiting for OutSystems to finish. We can test it in the browser, but as we have developed a mobile app, we can run it as a Progressive Web App on our mobile phone right away by scanning the QR-code:

 

And here you have it, the result:

 

You can download this OutSystems application from the Forge, so you can try it yourself:

 

You will see that we’ve added some more functionality which we haven’t all described in this article.

Wrapping up

With two platforms, an open-source AI model and some knowledge of software development, you can create your own AI-powered application. We did not focus on the performance of the deep learning model for this project, so not all objects will be detected correctly. However, the aim is to illustrate the ease of building an end-to-end application with just two platforms.

Would you like to build something similar? Feel free to create a free account with OutSystems and UbiOps. In case of any questions, let us know in the comments or simply reach out. We hope you enjoyed this read and hopefully, we gave you some inspiration for your own project!

About OutSystems

OutSystems was founded in 2001 with the mission to give every organization the power to innovate through software. The OutSystems modern application platform’s high productivity, connected, and AI-assisted tools help developers rapidly build and deploy a full range of applications anywhere the organization requires. With over 500,000 community members, approximately 1,600 employees, more than 400 partners, and active customers in 87 countries and across 22 industries, OutSystems has achieved global scale while helping organizations change the way they develop applications. Visit us at www.outsystems.com or follow us on Twitter @OutSystems or LinkedIn at https://www.linkedin.com/company/outsystems.

About UbiOps

UbiOps mission is to let every individual and organization operate and share their data-driven intelligence. UbiOps is a platform for deployment, management and serving of data science and ML/AI algorithms, which you can easily connect behind OutSystems. With UbiOps you can easily turn your Python & R models, functions and scripts into scalable live services without costly IT & software development. UbiOps makes fast real-world adoption of ML & AI possible for organizations, resulting in a higher ROI for data science projects. UbiOps is available in a SaaS version, a Private Managed version (hosted and managed by the UbiOps team, dedicated for a single customer) or a Private OnPremise version (installed and managed by the customer). UbiOps is ISO 27001 certified (information security). Follow us on LinkedIn at https://www.linkedin.com/company/ubiops.