Google Cloud: Optical Character Recognition (OCR) Tutorial

Learn how to perform optical character recognition (OCR) on Google Cloud Platform. This tutorial demonstrates how to upload image files to Google Cloud Storage, extract text from the images using the Google Cloud Vision API, translate the text using the Google Cloud Translation API, and save your translations back to Cloud Storage. Google Cloud Pub/Sub is used to queue various tasks and trigger the right Cloud Functions to carry them out.

Objectives

  • Write and deploy several Background Cloud Functions.
  • Upload images to Cloud Storage.
  • Extract, translate and save text contained in uploaded images.

Visualizing the flow of data

The flow of data in the OCR tutorial application involves several steps:

  1. An image that contains text in any language is uploaded to Cloud Storage.
  2. A Cloud Function is triggered, which uses the Vision API to extract the text and detect the source language.
  3. The text is queued for translation by publishing a message to a Pub/Sub topic. A translation is queued for each target language different from the source language.
  4. If a target language matches the source language, the translation queue is skipped, and text is sent to the result queue, another Pub/Sub topic.
  5. A Cloud Function uses the Translation API to translate the text in the translation queue. The translated result is sent to the result queue.
  6. Another Cloud Function saves the translated text from the result queue to Cloud Storage.
  7. The results are found in Cloud Storage as txt files for each translation.

It may help to visualize the steps:

Kinsta WordPress Hosting (Google Cloud)

Kinsta utilizes virtual machines in one of Google Cloud Platform’s multiple data centers. Each machine has up to 96 CPUs and hundreds of gigabytes of RAM. Hardware resources (RAM/CPU) are allocated to each site container automatically by our virtual machines on an as-needed basis.

Everything is interconnected over the highly reliable Google Cloud Platform’s “premium tier” network. This is designed to minimize distance and hops, resulting in faster more secure global transport of your data. Some hosting providers might opt for Google’s “standard tier” network service to cut costs, but we believe in only utilizing the best here at Kinsta.

LXD Logo
.. Google offers 19 locations throughout the USA, Europe, Asia-Pacific, and South America. They are strategically placed to offer the lowest latency anywhere in the world. This also results in blazing fast SFTP download and upload speeds.

Amazon Route 53 premium DNS is included for free for all Kinsta customers. Their global Anycast network, along with latency and geolocation routing help ensure your website is always online, stable, and has fast DNS lookup times.

We’ve also partnered up with KeyCDN, a real-time HTTP/2 and IPv6 powered content delivery network, with 35 POPs around the globe to speed up delivery of your assets (images, JS, CSS). Free bandwidth is included with every plan.

Google Cloud for Startups program

Startups in our program have access to:

  • Google Cloud credits, free users on G Suite, Hire by Google (US only), Qwiklabs, and more
  • Special events, mentorship, and technical training
  • News and product updates

Qualified startups

  • Have received no more than a Series A funding round
  • Are less than five years old
  • Are based in an approved territory
  • Have not previously received Cloud credits outside of the free-tier offering

Startups who are part of an incubator or accelerator program, or have received VC funding, should check with that organization before applying here as they may be eligible for larger credit levels.

Why Google’s Answer to AWS Reserved Instances is a Big Deal

This is in sharp contrast to what Amazon offers with RIs — pre-purchasing instance types, which have specific characteristics like “nice network instances” or “GPU instances” or “great storage instances”. Thus with Amazon you’re pre-purchasing a pre-set configuration of CPU/RAM/IOPS/Network/GPU/Disk characteristics with only minimal flexibility (mostly around EBS), and your mobility to other pre-set configurations is severely limited. So you better be damn sure you made the right choice, because you’re living with it for 1–3 years.

.. Google is able to offer this due to the unique nature of Google Cloud. Google Compute Engine under the hood is NOT a service that sells a bunch of VMs running on specific hardware. Compute Engine is an opinionated, living and breathing supercomputer, continuously carving out resources for its clients in the most optimal fashion

.. Do not discount (no pun intended) the technical complexity here. These problems are very very hard. As Eric Schmidt has said, Google’s poured $30 billion dollars over the past three years on this bonfire, and it shows. In the end, users win!