"When people look at my pictures I want them to feel the way they do when they want to read a line of a poem twice." - Robert Frank

EyeEm Vision - A fascinating look at the future of image recognition

By Cedric F. Jacob
2017-05-26

Two weeks ago Philipp, a friend of mine working for Runtastic, and I embarked on a trip to Berlin. We wanted to catch up with other businesses to engage in an exchange of knowledge and experience about customer service and the individual utilization of Zendesk. We had a great couple of days learning a lot during our short time with each company. One of these companies was EyeEm and I must admit, I was fascinated by their “product”.

About EyeEm

At first sight, EyeEm seems like “just another service offering stock photography”. Well, that was my first thought after doing a little bit of "research" before our meeting. But after just spending a few more minutes on their website, or if you are lucky like me, in their offices, one realizes: EyeEm seems to be quite different. But why?

EyeEm Website

EyeEm started off as a blog in 2010 and eventually grew into the platform known today. With a community of over 20 million creators they aim to connect photographers, brands and agencies. A truly impressive achievement. But what impressed me even more was the underlying technology. They claim that technology enables them to “organize and uncover the best images among millions of images uploaded each day” automatically. But how is this possible?

Beyond Image Recognition

As Michael Jones, Director of Content & Marketing, explained to me, EyeEm developed an algorithm called EyeEm Vision, a machine learning technology that understands aesthetics. I was intrigued and wanted to try the technology with one of my photos. By no means do I claim to be a professional photographer, but even someone like me can take a “great photo” once in a while. So I presented some of my photos to Michael allowing him to pick the one that would yield the least embarrassing results. And here they are:

EyeEm Vision

“Wow”, I thought. “This is amazing!”. Not only was I happy about the rating of “really good”, but I was amazed by the suggestion of tags and a caption for the photo. But really, before reading any further, you should try it out yourself.

Being a developer, I was in awe. I tried to imagine the complexity of what they had created and instantly wanted to play with it. Turns out you can!

It makes sense for EyeEm to offer an API allowing developers to use this functionality for their products and services.

EyeEm Vision API

EyeEm Vision API

I went ahead and requested an API key the same night by clicking on “Get Access” and signing up for a developer account. The necessary documentation is accessible after logging in. 

So how does it work?

First we will need to use the POST Token function to acquire the necessary access token. Once acquired, we can then use the POST Analyze function by providing the token in the authentication header.  

I decided to use PHP for my first and very rudimentary example:

<?php
 
define("Client_Id", "XXXXXXXX");
define("Client_Secret", "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
define("EyeEm_Url", "https://vision-api.eyeem.com/v1");
 
ffunction getToken()
{
	$ch = curl_init();
	curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true );
	curl_setopt($ch, CURLOPT_MAXREDIRS, 10 );
	curl_setopt($ch, CURLOPT_URL, EyeEm_Url."/token");
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
	curl_setopt($ch, CURLOPT_TIMEOUT, 10);
    
    curl_setopt($ch, CURLOPT_HTTPHEADER, array(
        'Content-Type: application/x-www-form-urlencoded'
    ));
    
     $values = array(
        'clientId'      => Client_Id,
        'clientSecret'  => Client_Secret
         );
    
    curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($values));
    
    $output = curl_exec($ch);
    
    if(curl_errno($ch)){
        echo 'Request Error:' . curl_error($ch);
    }
	curl_close($ch);
	return json_decode($output);
}
 
function analyzeImage($token, $imageurl)
{
	$ch = curl_init();
	curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true );
	curl_setopt($ch, CURLOPT_MAXREDIRS, 10 );
	curl_setopt($ch, CURLOPT_URL, EyeEm_Url."/analyze");
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
	curl_setopt($ch, CURLOPT_TIMEOUT, 10);
    
    curl_setopt($ch, CURLOPT_HTTPHEADER, array(
        'Content-Type: application/json',
        'Accept: application/json',
        'Authorization: Bearer '.$token
    ));
    
    
    $data_string = "{"requests":[{"tasks":[{"type":"TAGS"},{"type":"CAPTIONS"}, 
{"type":"AESTHETIC_SCORE"}],"image":{"url":"".$imageurl.""}}]}"; $data = json_decode($data_string); curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string); $output = curl_exec($ch); if(curl_errno($ch)){ echo 'Request Error:' . curl_error($ch); } curl_close($ch); return $output; } $token = getToken(); $data = analyzeImage($token->access_token, "http://www.cedricfjacob.com/assets/uploads/posts/id_23/Dennis.jpg"); echo $data; ?>

As previously mentioned, I am using the Client ID and Client Secret provided by EyeEm to generate a token. Next I am using the token to analyze a photo of mine.

The output looks something like this:

{
	"responses": [
		{
			"tags": [
				{
					"text": "one person",
					"probability": 0.9642419815063477
				},
				{
					"text": "beard",
					"probability": 0.920899510383606
				},
				{
					"text": "window",
					"probability": 0.9077731370925903
				},
				{
					"text": "real people",
					"probability": 0.8988518118858337
				},
				{
					"text": "t-shirt",
					"probability": 0.8770426511764526
				},
				{
					"text": "indoors",
					"probability": 0.7427080869674683
				},
				{
					"text": "headshot",
					"probability": 0.7282400727272034
				},
				{
					"text": "day",
					"probability": 0.5939185619354248
				},
				{
					"text": "standing",
					"probability": 0.5880111455917358
				},
				{
					"text": "one man only",
					"probability": 0.570299506187439
				},
				{
					"text": "lifestyles",
					"probability": 0.5557624101638794
				},
				{
					"text": "men",
					"probability": 0.5187975168228149
				},
				{
					"text": "only men",
					"probability": 0.31005969643592834
				},
				{
					"text": "young adult",
					"probability": 0.17499981820583344
				},
				{
					"text": "close-up",
					"probability": 0.16268131136894226
				},
				{
					"text": "adult",
					"probability": 0.06347451359033585
				},
				{
					"text": "adults only",
					"probability": 0.04672751575708389
				},
				{
					"text": "people",
					"probability": 0.021950745955109596
				}
			],
			"captions": [
				{
					"text": "CLOSE-UP OF MAN STANDING BY WINDOW"
				},
				{
					"text": "CLOSE-UP OF MAN STANDING AGAINST WINDOW"
				},
				{
					"text": "CLOSE-UP OF MAN STANDING ON WINDOW"
				},
				{
					"text": "CLOSE-UP OF MAN STANDING BY WINDOW IN OFFICE"
				}
			],
			"aesthetic_score": {
				"score": 0.5131391286849976
			}
		}
	]
}

The token is valid for 72 hours. So there is no need to acquire a new token every single time we want to analyze a photo.

My First Ideas

Being a gamer, two ideas came to mind:

  1. A browser-game, that asks the player to rate the aesthetics of 20-30 photos in a row. The goal is to get as close to the rating by EyeEm Vision as possible.
  2. A simulation game, in which the player needs to decide what photos to buy for their shop. Every day, the player gets to decide how to spend their virtual currency on photos provided by the "photographers". The higher the actual EyeEm Vision rating for the photo, the more likeley ist is, that someone will buy the photo and generate cash for the player.

I would love to create a small game using their API.

Imagine The Possibilities

The provided documentation is great and using the EyeEm Vision API to bring own ideas to life is within grasp for anyone. I will definitely experiment with the API and keep you guys updated about any use-case sceanrios I come up with. What do you think? Just imagine the possibilties!

Tags

Share

Discuss

Suggest a Topic

I am always happy to receive suggestions. So if you know about a cool game I might enjoy or you got a question about Zendesk, whatever it is, please let me know! I might end up writing about it.

Send me your suggestions!

Newsletter