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

10 Website Videos Mistakes and How to Solve Them

It should come as no surprise that video use on the internet is exploding. You can see the dramatic growth of video on the average site in this SpeedCurve blog post.

Average Website Weight over Time

With the growth in video comes greater bandwidth use, which is not only costly for your IT budget, but for your visitors as well. Beyond the expense, there is the user experience to consider. The heavier the page, the longer it will take to load, and the greater likelihood visitors will abandon your site. Page load speed is also an important factor in SEO ranking, so clearly video is something we need to take seriously and get right. Video is challenging, presenting terms still unfamiliar to developers - like codecs, bitrate and adaptive bitrate streaming. As a result, mistakes are being made in video implementation.

Read more
Android Data Saver: Optimizing Mobile Data Usage with Cloudinary

Over the life of a mobile device, the cost of a cellular data plan often exceeds that of the device itself. To optimize data usage and purge useless data on their mobile devices, users can enable Data Saver from Android 7.0 (API level 24). To do so, users toggle Data Saver in quick settings under the Notification shade or under Settings > Data usage. With Data Saver enabled, apps that aren't whitelisted cannot use cellular data in the background. They are also directed to consume less data while active.

Read more
Introducing the Cloudinary Upload Widget v2

At Cloudinary, we manage the entire pipeline of media assets for thousands of customers of varying sizes from numerous verticals. Cloudinary is an end-to-end solution for all your image and video needs, including upload, storage, administration, manipulation, optimization and dynamic delivery.

Read more
Convert an Image to a 3D Canvas With Cloudinary

Note
This post was cowritten with Daniel Mendoza.
Note
This post was cowritten with Daniel Mendoza.
Note

Famed American poet Henry David Thoreau once said, “This world is but a canvas to our imagination.” And, like your imagination, the transformations you can apply to images with Cloudinary are practically endless. You can even render any flat image to appear three-dimensional and framed on a canvas.

Read more
Mobile Optimization: Optimize Your Mobile-Web User Experience

TL;DR

We live in a visual world, often while on the go, and consumers expect media-rich web content. Accordingly, the loading speed of images and videos is a big factor in user experience. To optimize customer satisfaction with your mobile content, you must focus on the quality, format, and size of your digital assets. With Cloudinary, optimization is simple, not only enhancing your mobile web and app performance, but also upping your SEO game and boosting customer experience.

Read more