Skip to content
Proactively Stocking Inventory using Machine Learning
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
default-service
inventory-service
messaging-service
sample-images
staff-app
.gitignore
LICENSE
README.md
demo-architecture.png
setup.sh

README.md

Proactively Stocking Inventory using ML

Background

How do you notify store associates when items are out of stock? What if you could leverage footage from in-store cameras to detect when stock is low for items that have a quick turnover (like produce) and have those refilled before running out?

In this session from Google Cloud Next 2018, we walked through an architecture that describes how to combine camera footage, the Cloud Vision API, and Firebase to deliver an end-to-end use case to help shoppers get the products they need without having to wait.

Architecture

Demo Architecture

Process Flow

  • Images are uploaded to a Cloud Storage bucket
  • Cloud Storage bucket notifications are sent to a Cloud Pub/Sub topic
  • Cloud Pub/Sub push subscription sends message to App Engine Inventory service
  • Inventory service sends image to Cloud Vision API
  • Based on Vision API response, Inventory sends message to a Pub/Sub topic
  • Cloud Pub/Sub push subscription to App Engine Messaging service
  • Messaging service uses Firebase Admin API to send device notification
  • Firebase delivers push notification to Staff App

Requirements

Deploying

App Engine

$ gcloud app deploy \
default-service/app.yaml \
inventory-service/app.yaml \
messaging-service/app.yaml

Cloud Storage and Cloud Pub/Sub

Edit setup.sh with the following information:

  • Cloud Storage bucket name (BUCKET_NAME)
  • App Engine endpoints (INVENTORY_ENDPOINT and MESSAGING_ENDPOINT)
$ ./setup.sh all up

Firebase

In the Firebase console for your project, navigate to Project Settings > Cloud Messaging and create a new Web Push certificate. Next copy the Key pair and paste it into messaging.usePublicVapidKey() in staff-app/index.html.

$ cd staff-app
$ firebase deploy

Once the Firebase app has been deployed, navigate to it and generate a new push token. Copy that token and run the following:

$ ./update-metadata.sh [TOKEN]
You can’t perform that action at this time.