Here is the scenario. You work for a startup that develops a platform that allows photographers (both professionals and amateurs) to upload and share their lovely pictures with other photography lovers.
The platform has been online for more than 2 years now and has been very successful. Users have uploaded more than 5 million pictures already.
Your product owner comes to you requesting a killer feature that allows users to search for photos, even those that haven’t been tagged nor received any description yet.
You are requested to come up with a cheap and fast solution to the problem. Now what?
Google Cloud to the rescue!
In this series of articles, we are going to see how to build a solution that leverages Android, Firebase and Google Cloud Vision API for streamlining image tagging in the cloud with a serverless structure.
In this first part, we are going to focus on configuring a Google Cloud project with Google Cloud Vision API enabled. In the parts that follow, we’ll see how to configure Firebase services and how to create a basic Android app for uploading the photos.
Let’s get it started!
Google Cloud Vision API showcase
Google describes this service as follows:
Google Cloud Vision API enables developers to understand the content of an image by encapsulating powerful machine learning models in an easy to use REST API. It quickly classifies images into thousands of categories (e.g., “sailboat”, “lion”, “Eiffel Tower”), detects individual objects and faces within images, and finds and reads printed words contained within images. You can build metadata on your image catalog, moderate offensive content, or enable new marketing scenarios through image sentiment analysis. Analyze images uploaded in the request or integrate with your image storage on Google Cloud Storage.
For our use case, we are going to focus on image classification. We are going to use it to tag our images, so they can be searched by our platform users.
The first thing we need to do in order to use the API is to create a Google Cloud Project. To do so, follow these steps:
Project selection menu
Project selection dialog
Cool! You have just created your Google Cloud project, which is going to be used for managing the APIs used in this series.
Time to enable the Google Cloud Vision API for the project. To do so, follow the steps below:
Opening API Manager Library
Searching for the Google Cloud Vision API
Google Cloud Vision API page (for this tutorial, we are going to use Server-to-server interaction)
Google Cloud Vision API dashboard
Next and final step for using the API is creating an API Key for authenticating our calls to the service. Let’s get it done:
Opening API Manager Credentials
Creating our API Key
Time to test our precious work! In order to do this, we are going to perform a HTTP request to the API. For this, we are going to use the following JSON template:
Notice we use __IMAGE_URI__ as the value for imageUri field. This placeholder will be replaced with sed when we call the API:
What’s happening here?
The result is the following:
It works! From the results, we can see the API is more than 97% sure it’s a mug and more than 94% sure it’s orange. Below is the image we analyzed. As you can see, the API yielded pretty good results:
Our not so beauty analyzed orange mug
Finally, if you check the Google Cloud Vision API dashboard again, you should see it now displays updated data:
Google Cloud Vision API dashboard now displays some data
In this first part, we have seen what is Google Cloud Vision API about, how easy it is to create a Google Cloud project and enable the Vision API for it, how easy it is to use the API and, of course, how impressively accurate the API is.
Stay tuned for the next parts, as we are going to see how to configure Firebase and integrate it with the API, as well as how to create a basic Android.
Hope you liked it!
Thanks for reading! If you found this helpful or interesting please ❤ it. Also, feel free to share your thoughts in the comments below.