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:
cloudinary.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")
Android:
MediaManager.get().url().generate("dance_party.jpg");
iOS:
imageView.cldSetImage(cloudinary.createUrl().generate("dance_party.jpg")!, cloudinary: cloudinary)
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"=>
      "https://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 a WhatsApp Clone with Automatic Image Optimization

In the previous post, we showed how to upload images to a Cloudinary server. In this part, we will play with some of the features we see on the WhatsApp technology. After you or your users have uploaded image assets to Cloudinary, you can deliver them via dynamic URLs. You can include instructions in your dynamic URLs that tell Cloudinary to manipulate your assets using a set of transformation parameters. All image manipulations and image optimizations are performed automatically in the cloud and your transformed assets are automatically optimized before they are routed through a fast CDN to the end user for an optimal user experience. For example, you can resize and crop, add overlays, blur or pixelate faces, apply a variety of special effects and filters, and apply settings to optimize your images and to deliver them responsively.

Read more
With automatic video subtitles, silence speaks volumes

The last time you scrolled through the feed on your favorite social site, chances are that some videos caught your attention, and chances are, they were playing silently.

On the other hand, what was your reaction the last time you opened a web page and a video unexpectedly began playing with sound? If you are anything like me, the first thing you did was to quickly hunt for the fastest way to pause the video, mute the sound, or close the page entirely, especially if you were in a public place at the time.

Read more
Impressed by WhatsApp Tech? Build WhatsApp Clone with Media Upload

With more than one billion people using WhatsApp, the platform is becoming a go-to for reliable and secure instant messaging. Having so many users means that data transfer processes must be optimized and scalable across all platforms. WhatsApp is touted for its ability to achieve significant media quality preservation when traversing the network from sender to receiver, and this is no easy feat to achieve.

Read more
New Google-powered add-on for auto video categories and tags

Due to significant growth of the web and improvements in network bandwidth, video is now a major source of information and entertainment shared over the internet. As a developer or asset manager, making corporate videos available for viewing, not to mention user-uploaded videos, means you also need a way to categorize them according to their content and make your video library searchable. Most systems end up organizing their video by metadata like the filename, or with user-generated tags (e.g., youtube). This sort of indexing method is subjective, inconsistent, time-consuming, incomplete and superficial.

Read more

iOS Developer Camp: The Dog House

By Shantini Vyas
iOS Developer Camp: The Dog House

Confession: I’m kind of addicted to hackathons. Ever since graduating from Coding Dojo earlier this year, I’ve been on the hunt for new places to expand my skills and meet new people in the tech space. iOS Developer Camp’s 10th Anniversary event bowled me over. Initially, because of its length. 48 hours? Yeesh. I had no idea that those 48 hours would change my life. But let’s first get a little backstory on my favorite topic: dogs.

Read more