Build a real-time object identifier using OCI Vision and Oracle Autonomous Database

Learn how to build a real-time object-identifying vision model using Oracle Cloud Infrastructure (OCI) Vision, Oracle Functions, API Gateway, and Oracle Autonomous Database (ADB). This reference architecture describes how you can integrate an OCI Vision-trained model with a front-end web app to perform real-time object identification with a mobile phone camera.

Architecture

OCI Vision is an artificial intelligence (AI) service for performing large-scale deep-learning-based image analysis. With prebuilt models available, developers can quickly build image recognition into their applications without machine learning expertise.

Vision models use artificial intelligence to enable computers to derive information from images. This architecture uses a terraform script to create a web application that uses the OCI Vision model to perform real-time object identification using a mobile phone camera.

This architecture includes an optional web application that developers can use to perform real-time object identification. After the web application setup is complete, users can open the web app on their mobile phones, activate the camera, and take a snapshot. The app analyzes images and returns image details.

A request is sent to the serverless function to call the OCI Vision service and the database (using python OCI SDK). The vision service then returns a list of labels with a confidence score, and the database helps to save the details on the list of available labels. The function service is useful in scenarios where there is no need to have a service active all the time, or when there are loose restrictions on the response time (because the function service requires warm up time). The benefit however, is that you are only charged for the compute time the function is active, therefore it can be very cost effective.

You can use the architecture as it is with the web app for rapid testing, and use all the resources available in the repository. You also may want to incorporate the vision model into your own tenant, to modify the script to remove the front-end proposed architecture (the load balancer and web servers) and use the API Gateway to call the function when it is needed from your own backend services.

The vision service can be used for image classification, object detection, and document analysis. The vision service contains pre-trained models for general purposes, but it can also be used with the data labeling service to create custom models for specific data you have. The terraform script provides access to create a general architecture to use the vision service.

The following diagram illustrates this reference architecture.



aivision-realtime-deployment.zip

The architecture has the following components:

  • Region

    An Oracle Cloud Infrastructure region is a localized geographic area that contains one or more data centers, called availability domains. Regions are independent of other regions, and vast distances can separate them (across countries or even continents).

  • Availability domains

    Availability domains are standalone, independent data centers within a region. The physical resources in each availability domain are isolated from the resources in the other availability domains, which provides fault tolerance. Availability domains don’t share infrastructure such as power or cooling, or the internal availability domain network. So, a failure at one availability domain is unlikely to affect the other availability domains in the region.

  • Fault domains

    A fault domain is a grouping of hardware and infrastructure within an availability domain. Each availability domain has three fault domains with independent power and hardware. When you distribute resources across multiple fault domains, your applications can tolerate physical server failure, system maintenance, and power failures inside a fault domain.

  • Virtual cloud network (VCN) and subnets

    A VCN is a customizable, software-defined network that you set up in an Oracle Cloud Infrastructure region. Like traditional data center networks, VCNs give you complete control over your network environment. A VCN can have multiple non-overlapping CIDR blocks that you can change after you create the VCN. You can segment a VCN into subnets, which can be scoped to a region or to an availability domain. Each subnet consists of a contiguous range of addresses that don't overlap with the other subnets in the VCN. You can change the size of a subnet after creation. A subnet can be public or private.

  • Internet gateway

    The internet gateway allows traffic between the public subnets in a VCN and the public internet.

  • Network address translation (NAT) gateway

    A NAT gateway enables private resources in a VCN to access hosts on the internet, without exposing those resources to incoming internet connections.

  • Load balancer

    The Oracle Cloud Infrastructure Load Balancing service provides automated traffic distribution from a single entry point to multiple servers in the back end.

  • Route table

    Virtual route tables contain rules to route traffic from subnets to destinations outside a VCN, typically through gateways.

  • API Gateway

    Oracle API Gateway enables you to publish APIs with private endpoints that are accessible from within your network, and which you can expose to the public internet if required. The endpoints support API validation, request and response transformation, CORS, authentication and authorization, and request limiting.

  • Autonomous Database

    Oracle Cloud Infrastructure Autonomous Database is a fully managed, preconfigured database environments that you can use for transaction processing and data warehousing workloads. You do not need to configure or manage any hardware, or install any software. Oracle Cloud Infrastructure handles creating the database, as well as backing up, patching, upgrading, and tuning the database.

  • Functions

    Oracle Functions is a fully managed, multitenant, highly scalable, on-demand, Functions-as-a-Service (FaaS) platform. It is powered by the Fn Project open source engine. Functions enable you to deploy your code, and either call it directly or trigger it in response to events. Oracle Functions uses Docker containers hosted in Oracle Cloud Infrastructure Registry.

  • Object storage

    Object storage provides quick access to large amounts of structured and unstructured data of any content type, including database backups, analytic data, and rich content such as images and videos. You can safely and securely store and then retrieve data directly from the internet or from within the cloud platform. You can seamlessly scale storage without experiencing any degradation in performance or service reliability. Use standard storage for "hot" storage that you need to access quickly, immediately, and frequently. Use archive storage for "cold" storage that you retain for long periods of time and seldom or rarely access.

  • Vault

    Oracle Cloud Infrastructure Vault enables you to centrally manage the encryption keys that protect your data and the secret credentials that you use to secure access to your resources in the cloud.

  • Vision

    Oracle Cloud Infrastructure Vision is an AI service for performing deep-learning–based image analysis at scale. With prebuilt models available out of the box, developers can easily build image recognition and text recognition into their applications without machine learning (ML) expertise.

  • OCI Data Labeling

    The OCI Data Labeling service is an OCI native service that allows customers to create and browse datasets, view data records (text, images) and apply labels for the purposes of building AI/ML models. The service also provides interactive user interfaces designed to aide in the labeling process. Developers can upload raw images, add labels, and highlight areas of images. By adding these labels to images, the resulting datasets can be used to train custom image classification and object-detection models.

    Once records are labeled, the dataset can be exported as line-delimited JSON for use in AI/ML model development. OCI Data Labeling can also be accessed directly from other services such as OCI Vision and OCI Language as part of a custom model-training workflow. Data scientists who prefer to build and train their own deep learning or natural language processing models can consume the labeled dataset through OCI Data Science.

Deploy

The code required to deploy this reference architecture is available in GitHub. You can download the code from GitHub to your computer, customize the code, and deploy the architecture by using the Terraform CLI.

  1. Go to GitHub.
  2. Clone or download the repository to your local computer.
  3. Follow the instructions in the README document.

Acknowledgments

Author: Carlos Giraldo

Contributor: Badr Tharwat