Cloudinary Blog

How to automatically tag and categorize photos according to their content

How to automatically tag and categorize photos by their content

Update - December 2015: The add-on described in this post is no longer available since ReKognition terminated their services. However, all features described here are still available via a different and even better add-on by Imagga. See Automatic image categorization and tagging with Imagga and the Imagga Auto Tagging Add-on documentation.

Drawing insights from user generated content can be very useful. If you allow users to upload images, you might want to better understand what their images contain. Whether a photo is of a landscape, people, animals, or nightlife, image processing and analysis can assist in further comprehension.

ReKognition scene categorization

Cloudinary takes care of the entire image management pipeline, from uploading, via dynamic image manipulation, to fast CDN delivery. You can use Cloudinary with our add-on for automatic scene categorization provided by ReKognition, a visual recognition solution developed by Orbe.us.

ReKognition logo The ReKognition scene categorization add-on analyzes scenes within photos and allows you to automatically classify your website’s images into a long list of potential categories.

Improve user experience, engagement and conversion

By automatically recognizing what images contain, developers can easily create pages or site sections based on images’ content (e.g. photos of animals, travel, special events, etc.). In addition, if your site supports a search option, you can have the search results include relevant images based on their visual content instead of just by their file names or user-assigned tags. These benefits can improve user experience on your site and increase engagement.

When you identify image content, you then know what images your users upload or search for and can target them with related content in order to enhance engagement and conversion. For example, if a user uploaded or searched for cat images, you can target him/her with actions, such as presenting pictures of other pets or any cats’ related content. Knowing the content of images on your site can have a direct impact on your online business.

How-to automatically categorize your images

Web and mobile developers can use Cloudinary's API to process images while uploading or process previously uploaded images.

For example, the image below was uploaded to Cloudinary using the code below. You can see that the image’s content is clearly of a dance party, so let’s see how it is categorized with the ReKognition add-on. Simply set the categorization upload parameter to rekognition_scene in order to perform the image’s content analysis and get the detected categories:

Cloudinary::Uploader.upload("my_dance_photo.jpg",
          :categorization => 'rekognition_scene', 
          :public_id => "dance_party")

Ruby:
cl_image_tag("dance_party.jpg")
PHP:
cl_image_tag("dance_party.jpg")
Python:
CloudinaryImage("dance_party.jpg").image()
Node.js:
cloudinary.image("dance_party.jpg")
Java:
cloudinary.url().imageTag("dance_party.jpg")
JS:
cl.imageTag('dance_party.jpg').toHtml();
jQuery:
$.cloudinary.image("dance_party.jpg")
React:
<Image publicId="dance_party.jpg" >

</Image>
Angular:
<cl-image public-id="dance_party.jpg" >

</cl-image>
.Net:
cloudinary.Api.UrlImgUp.BuildImageTag("dance_party.jpg")
Sample dance party uploaded photo

Cloudinary’s upload API's result shows the uploaded image's detected categories as well as their level of accuracy, provided as a score between 0 and 1, where 1 is 100% accurate. As you can see in the example below, the ReKognition add-on detected several categories for the image above, that were each given a score. The best category match was 'dance', with a 0.719 accuracy score.  

    {"public_id"=>"dance_party",
     "url"=>
      "http://res.cloudinary.com/demo/image/upload/v1417446163/dance_party.jpg",
     ...
     "info"=>
      {"categorization"=>
        {"rekognition_scene"=>
          {"status"=>"complete",
           "data"=>
            {"matches"=>
              [{"tag"=>"dance", "score"=>0.719},
               {"tag"=>"blonde", "score"=>0.3055},
               {"tag"=>"model", "score"=>0.24},
               {"tag"=>"night_club", "score"=>0.1859},
               {"tag"=>"hair", "score"=>0.1449}]}}}},
    }

Image categorization data can be stored on your side in order to organize your content and target user interest. You can then take actions such as linking the categorization data to users that upload categorically related images. Once the information is captured, a data analysis can take place generating insights, including users’ image preferences. Based on the information and analysis provided, you will be able to take proactive actions to enhance user engagement and conversion.

Automatic tagging with ReKognition scene categorization

Cloudinary allows you to tag uploaded images. Each image can be assigned one or more tags. This feature automatically assigns tags based on categories that are detected by the ReKognition add-on.

You can see below that we set the auto_tagging parameter to 0.15 for the dance party example image above, which means that auto tagging will use the detected categories above this threshold. You can set the threshold to a higher level if you want to be more strict regarding the detected categories you want to tag. As for our example, the tagging results were 'blonde', 'dance', 'model', and 'nightclub':

Cloudinary::Uploader.upload("my_dance_photo.jpg", 
      :categorization => 'rekognition_scene', 
      :auto_tagging => 0.15, 
      :public_id => "dance_party")

Results in:

    "tags" => ["blonde", "dance", "model", "night_club"]

With automatic tagging using ReKognition’s scene categorization add-on, you will be able to use Cloudinary's admin API in order to list and search for all images with specific tags.

Summary

Understanding user generated content can provide you with great insights, allow you to take actions such as creating dynamic content pages, and match content to user preferences. Cloudinary’s service together with the fully integrated ReKognition scene categorization add-on provides developers with the powerful ability to enhance their image content management as well as increase their online users’ engagement and conversion.

ReKognition add-on

The ReKognition scene categorization add-on is available with all Cloudinary plans, You can try it out with the add-on’s free tier. If you don't have a Cloudinary account yet, sign up for a free account here.

Update - December 2015: The add-on described in this post is no longer available since ReKognition terminated their services. However, all features described here are still available via a different and even better add-on by Imagga. See Automatic image categorization and tagging with Imagga and the Imagga Auto Tagging Add-on documentation.

Recent Blog Posts

Build the Back-End For Your Own Instagram-style App with Cloudinary

Github Repo

Managing media files (processing, storage and manipulation) is one of the biggest challenges we encounter as practical developers. These challenges include:

A great service called Cloudinary can help us overcome many of these challenges. Together with Cloudinary, let's work on solutions to these challenges and hopefully have a simpler mental model towards media management.

Read more

Build A Miniflix in 10 Minutes

By Prosper Otemuyiwa
Build A Miniflix in 10 Minutes

Developers are constantly faced with challenges of building complex products every single day. And there are constraints on the time needed to build out the features of these products.

Engineering and Product managers want to beat deadlines for projects daily. CEOs want to roll out new products as fast as possible. Entrepreneurs need their MVPs like yesterday. With this in mind, what should developers do?

Read more

Your Web Image is Unnecessarily Bloated

By Christian Nwamba
Your Web Image is Unnecessarily Bloated

As a developer, it seems inefficient to serve a 2000kb JPEG image when we could compress images to optimize the performance without degrading the visual quality.

We are not new to this kind of responsibility. But our productivity will end up being questioned if we do not deliver fast. In order to do so, the community has devised several patterns to help improve productivity. Let's review few of these patterns based on their categories:

Read more

Google For Nigeria: We saw it all…

By Christian Nwamba
Google For Nigeria: We saw it all…

Note from Cloudinary: Christian Nwamba, a frequent Cloudinary contributor, recently attended, and was a main speaker, at the Google Developer Group (GDG) Conference in Lagos, Nigeria. Christian led a session teaching more than 500 developers how to “Build Offline Apps for the Next Billion Users.” The stack he used included JS (Vue), Firebase, Service Workers and Cloudinary. Below is his account of the conference and his talk.

Read more
Viral Images: Securing Images and Video uploads to your systems

When was the last time you got paid $40,000 for a few days of work? That is what happened last year to Russian independent security researcher Andrey Leonov, who discovered that if you upload a specially constructed image file to Facebook, you can make Facebook's internal servers, nested deep within their firewalls, run arbitrary commands to expose sensitive internal files in a way that could easily lead to a data breach.

Read more