New Exclusive Deal:

Up To 78% OFF a New Website

02

:

23

:

46

:

00

All Categories
Business ideas Design eCommerce blog Inspiration Marketing Small business heroes Small business tips Web essentials Zyro insights Zyro news

Zyro as a Frontend for Machine Learning – Facial Recognition

In my last post, I was experimenting with the way that the Zyro builder could be used as a front end to speed up the development of a machine learning project.

I created a text sentiment classification service that was able to identify whether a given statement was positive, neutral or negative.

Now, I am experimenting again, and this time I wanted to create a tool that is able to find faces in an image. 

The method

So, here is how this is going to work:

  1. The user enters the URL of an image that he wants to find faces in. 
  2. This image URL is sent to a backend where all heavy lifting is done (image download, face searching, and response generation.) 
  3. The front end will receive an image with all the faces detected and display it for the user. 

Sounds simple, right? 

And now that we have a vision in place it’s time to get our hands dirty 💪

The tools

The whole project is actually made from just a two parts:

  • Google Cloud Function. This is used for creating the REST API and deploying the face detection model
  • Zyro website builder. This is used for the frontend of the face detection service

The project

Okay, so first of all we need to create a Cloud Function.

In this case I am naming it facesfinder, selecting HTTP as the trigger type and marking “Allow unauthenticated invocations”

I’m doing that just to make the development of the API easier, so I don’t have to deal with any authentication stuff.

Cloud function set up 1

Next, we need to set the runtime parameters. 

I am selecting 1 GB of memory allocated and setting Autoscaling to 1 (for demonstration purposes). All the other parameters are going to be left on the default settings.

Cloud function set up 2

For programming the Cloud Function logic I am going to be using Python and one additional library: OpenCV

The whole logic is very similar to my sentiment prediction service but there are some differences.

That’s mainly in the fact that no separate machine learning model is needed because OpenCV has one built in.

Also, instead of receiving and responding with a text service, it is going to receive and send an image as a response.

So, to help this process along there is one trick that I am implementing – if the user provides a URL that does not link to an image, I set the default URL to use  👍. 

As always, all the code for the Google Cloud Function can be found in this GitHub repository

Cloud function setup 3
Cloud function setup 4

So, everything looks good but before we move forward we need to test if the function is working correctly. You could use Postman or other similar tools for that 😉

Now that we have the backend working we can move on to frontend development. 

To speed up the development process I am reusing some code that I wrote for a sentiment classification project

Of course, the main difference is that instead of displaying text as a response I need to display an image.

Cloud function setup 5

Instead of a json type response, I am receiving a blob type response and in order to display the image that is stored in the blob object we need to create a URL that directs to that object by executing a createObjectURL function (again, the whole embed code can be found in the GitHub repository.)

And there we have it: finally, a face finding service ready to accept a whole world of traffic 🚀

You can check the final result of my project here.

Face Finder demo page

And, of course, here are few live demos 💪.

There is no end to the interesting things that we make at Zyro, whether it’s a little project like this or something like our AI Heatmap tool, we never stop experimenting because it’s the best way to learn.

If you’re into AI, we’ve got a whole bunch of articles written directly by the experts in our AI team who are waiting to share their knowledge with you, so what are you waiting for?

Need help building your website?

Download your essential guide to building a modern, professional website with Zyro.

I agree to receive marketing communications from Zyro. Unsubscribe at any time.

Written by

Author avatar

Tomas Rasymas

Tomas is Zyro’s Data Science Team Lead. He and his talented team generate insights which help make Zyro better for users. He is most passionate about finding smart AI solutions for tasks big and small. He’s also a lowkey expert on machine voice recognition.

Join the conversation

Your email address will not be published. All fields are required.

Save your name and email in this browser.

Need help building your website?

Download your essential guide to building a modern, professional website with Zyro.

I agree to receive marketing communications from Zyro. Unsubscribe at any time.