Recognizing celebrities in an image with Sightengine

We will see in this article how to detect if an image contains celebrities with Sightengine.

Sightengine is an API that lets you to moderate images and videos. There are 8 models currently available.

  • Nudity detection (i.e. detect adult or suggestive content)
  • Weapons/Alcohol/Drugs detection
  • Face/People detection (i.e. detect if the image contains a person or several people or nobody, along with the positions of those faces)
  • Face Attributes detection (get the age group and gender, determine if a face is covered with sunglasses…)
  • Celebrity detection
  • Image type detection (i.e. detect if the image is a natural photograph or an illustration)
  • Image Properties (i.e. determine the quality of an image along with its main colors)
  • Scammer detection (detect if an image is likely to have been submitted by a romance scammer)
  • Flask: Creates a web server
  • Sightengine: The SDK that will allow us to automatically moderate our images

We will in our case use the model celebrities to detect if an image contains celebrities with Sightengine.

Here is an example of output for an image with the actor Daniel Craig:

We will use the python language in this tutorial. You can use another language if you want.

Use Sightengine

You must first register on Sightengine’s website, it’s totally free. Just click on the get started button and create an account.

Sightengine works with two keys, we will need these keys to use the SDK in our application. Be careful, do not share them, they are secret keys.

We need to install the SDK of Sightengine. This SDK allow us to use the API with in our application.

pip install sightengine

We will retrieve an image that we will send to Sightengine. Sightengine will analyze this image and detect if there are celebrities or not.

Sightengine return a JSON, in this JSON there is an object for each person present on the image. In this object there is a celebrity attribute that is an array containing potential celebrities.

If the probability of the first object in this array is large (in our case greater than 85) there is a good chance that the person is a celebrity.

# Final thoughts

I hope this was helpful. If you want to know more about Sightengine you can try their demo. Feel free to share and recommend if useful :)