My plan for a content based image search

I saw this job posting from EyeEm, a photo sharing app / service, in which they express their wish/plan to build a search engine that can ‘identify and understand beautiful photographs’. That got me thinking about how I would approach building a system like that.

Here is how I would start:

1. Define what you are looking for

eyeem.brandenburgertorEyeEm already has a search engine based on tags and geo-location. So I assume, they want to prevent low quality pictures to appear in the results and add missing tags to pictures, based on the image’s content. One could also group similar looking pictures or rank those pictures lower which “don’t contain their tags”.  For instance for the Brandenburger Tor there are a lot of similar looking pictures and even some that don’t contain the gate at all.

But for which concepts should one train the algo-rithms? Modern image retrieval systems are trained for hundreds of concepts, but I don’t think it is wise to start with that many. Even the most sophisticated, fine tuned systems have high error rates for most of the concepts as can be seen in this year’s results of the Large Scale Visual Recognition Challenge.

For instance the team from EUVision / University of Amsterdam, placed 6 in the classification challenge, only selected 16 categories for their consumer app Impala. For a consumer application I think their tags are a good choice:

  • Architecture
  • Babies
  • Beaches
  • Cars
  • Cats (sorry, no dogs)
  • Children
  • Food
  • Friends
  • Indoor
  • Men
  • Mountains
  • Outdoor
  • Party life
  • Sunsets and sunrises
  • Text
  • Women

But of course EyeEm has the luxury of looking at their log files to find out what their users are actually searching for.

And on a comparable task of classifying pictures into 15 scene categories a team from MIT under Antonio Torralba showed that even with established algorithms one can achieve nearly 90% accuracy [Xiao10]. So I think it’s a good idea to start with a limited number of standard and EyeEm specific concepts, which allows for usable recognition accuracy even with less sophisticated approaches.

But what about identifying beautiful photographs? I think in image retrieval there is no other concept which is more desirable and challenging to master. What does beautiful actually mean? What features make a picture beautiful? How do you quantify these features? Is beautiful even a sensibly concept for image retrieval? Might it be more useful trying to predict which pictures will be `liked` or `hearted` a lot? These questions have to be answered before one can even start experimenting. I think for now it is wise to start with just filtering out low quality pictures and to try to predict what factors make a picture popular.

2. Gather datasets

Not only do the systems need to be trained with example photographs for which we know the depicted concepts, we also need data to evaluate our system to be sure that the implemented system really works as intended. But to gather useful datasets for learning and benchmarking is one of the hardest and most overlooked tasks. To draw meaningful conclusions the dataset must consist of huge quantities of realistic example pictures with high and consistent metadata. In our case here, I would aggregate existing datasets that contain labeled images for the categories we want to learn.

For starters the ImageNet, the Scene Understanding and the Faces in the Wild databases seem usable. Additionally one could manually add pictures from Flickr, google image search and EyeEm’s users.

Apart from a rather limited dataset of paintings and pictures of nature from the Computational Aesthetics Group of the University Jena, Germany, I don’t know any good dataset to evaluate how well a system detects beautiful images. Researchers either harvest photo communities that offer peer-rated ‘beautifulness’ scores such as photo.net [Datta06] or dpchallenge.com [Poga12], or they collect photos themselves and rate the pictures themselves for visual appeal [Poga12, Tang13].

The problem with datasets harvested from photo communities is that they suffer from self selection bias, because users only upload their best shots. As a result there are few low quality shots to train the system.

Never the less I would advise to collect the data inhouse. If labeling an image as low quality takes one second, one person can label 30.000 images in less then 10h. And even if we accept that one picture has to be labeled by multiple persons to minimize unwanted subjectivity, this approach would ensure, that the system has the same notion of beauty as favored by EyeEm.

3. Algorithms to try

I would start with established techniques like the Bag of visual Words approach (BoW). As the before mentioned MIT paper describes, over 80% accuracy can already be achieved with this method for a comparable task of classifying 15 indoor and outdoor scenes [Xiao10]. While this approach originally relies on the patented SIFT feature detector and descriptor, one can choose from a whole list of new free alternatives, which deliver comparable performance while being much faster and having a lower memory footprint [Miksik2012].  In the MIT paper they also combined BoW with other established methods to increase the accuracy to nearly 90%.

The next step than would be to use Alex Krizhevsk’s implementation of a deep convolutional neural network which he used to win last year’s Large Scale Visual Recognition Challenge. The code is freely available online. While being much more powerful this system is also much harder to train, with many parameters to train with out good existing heuristics.

But these two approaches wont really help assessing the beauty of pictures or identifying the low quality ones. If one agrees with Microsoft Research’s view of photo quality, defined by simplicity, (lack of) realism and quality of craftsmanship, one could start with the algorithms they designed to classify between high quality professional photos and low quality snapshots. [Ke06]

Caveats

Specific for the case at hand I predict that the filters will cause problems. They change the colors and some of them add high and low frequency elements. This will decrease the accuracy of the algorithm. To prevent this the analysis has to be performed on the phone or the unaltered image has to be uploaded as well.

Low quality or not?

If I remember correctly I once read that EyeEm applies the filters in full resolution to pictures on their servers and downloads the result to the user’s phones afterwards. If this is still the case both approaches are feasible. But as phones get more and more powerful a system which works on the phone is to be preferred as it is inherently more scalable.

Another challenge would be to distinguish between low quality pictures and pictures that break the rules of photography on purpose. The picture on the right for example has a blue undertone, low contrast and is quite blurry. But while these features make this image special, they would also trigger the low quality detector. It will be interesting to see if machine learning algorithms can learn to distinguish between the two cases.

So to recap:

1. Make sure the use case is sound.
2. Collect loads of data to train and evaluate.
3. Start with simple, proven algorithms and increase the complexity step by step.

Image retrieveal with the consumer in mind

As a continuation of my blog post Assumptions about the end user I want to explain what else should be thought of when designing image retrieval systems with the end user in mind.

Don’t cause the user more work

To summarize the post I mentioned above: “Algorithms should not create new work for the user, but remove (some of) it.” An algorithm should be rather conservative in its decisions, because a user will perceive an algorithm that, for instance creates wrong tags, that the user have to correct in the end, as faulty at not helpful at all.

Don’t dethrone the user

Also to often there is no option for the user to easily override the decision of the algorithm, without the need to disable it and losing all the support.

Lifelong learning

The algorithm should not only allow me to retag an image or move it to a different cluster, but use this information to retag other affected images and make better decisions in the future.

For instance Wang et al. show in Intelligent photo clustering with user interaction and distance metric learning how it is possible to use corrections made by the user to improve the distance calculation for photo clustering.

Solving the wrong problem

Unfortunately unconstrained* object recognition is still far from solved and useable. The best system so far is the one from Alex Krizhevsky (University of Toronto) using Deep Convolutional Neural Networks.

His system achieved a top-5 error rate** of 15.3%, compared to 26% of the second best system for one of the most demanding benchmark databases with 1.2 million images and 1000 object classes.

That’s very impressive, but it also means, that every 6th image gets assigned 5 labels, which are incorrect.

Nevertheless this system was so ground breaking that he together with his supervisor, Geoffrey Hinton, and another grad student where hired by Google in March of this year.
This system now runs the google+ photo search.

But do we need such a system? What does it help you if the algorithm detects that there is a plant or a chair in your images? Isn’t it much more useful to analyze the scene of the picture, to tag pictures with broader scene descriptions like, group picture, living room or mountains?

In 2010 a team from MIT and Brown University showed, that even with existing methods on can achieve 90% recognition for 15 different scene classes like office, living room, inside city and forest with only 100 training images per class.

The authors wanted to push their new dataset, that contains nearly 400 scene classes, for which they reach a recognition rate of just under 40%. While academically much more demanding and thus interesting, I don’t think consumers have a use for a system that can differentiate an oil refinery from an ordinary factory most of the time.

I am convinced that a simpler system, that gets a few categories right ‘all’ the time, is much more useful.

* unconstrained means that the algorithm does not need the environment or the object to be controlled in some way.
Most working system only work with lighting or background, perspective and with no or limited clutter and occlusion.

** top-5 error rate is the fraction of test images for which the correct label is not among the five labels considered most probable by the model

AI, the new secret weapon in the cloud photo-storage war.

Gigaom posted an article on “The Dropbox computer vision acquisition that slipped under the radar“. But I think it the article should have been called:

AI, the new secret weapon in the cloud photo-storage war.

Okay, this title is probably a hyperbole. But all the big internet companies offer a way to store and share your photos online. And to make their offer more compelling Yahoo, Google, and Dropbox all recently bought computer vision start-ups that will provide image recognition for their user’s uploaded photos. While Yahoo bought LookFlow, Google bought DNNresearch.

Microsoft is researching on image recognition for a long time and I am sure they will soon integrate some of their algorithms into their cloud products. And Facebook just founded an internal AI group.

And to get a look into the future without having to upload all your photographs to the internet, try the iOS app Impala. The app will analyse and categorise all your photographs on your device. It was created by EUVision technologies, a spin off of the University of Amsterdam commercializing their research efforts. 

After the negative conclusion from my last post about the closure of Everpix these are positive news for the machine learning market.

The end of Everpix, a sad week for photographers and machine learning researchers.

This week the photo storage service Everpix announced, that they will close down. They did not have enough paying costumers and could not find new investors.

That is sad. Not only because it was the world’s best photo startup according to the Verge, but also because it was the only company besides Google that used new machine learning techniques to help people manage their photo mess.

everpix home screen

Everpix home screen

Their closure can be seen as an indicator that end users and investors are not ready yet to spend additional money on machine learning algorithms.

Flashback mail

Flashback mail

Having read some articles and the associated comments[1, 2], it is clear to me that not their use of sophisticated machine learning algorithms but the daily ‘flashback’ email with pictures taken on the same day in previous years was the more popular feature. In fact, I did not even see one single comment about the algorithms that analysed the pictures.

But maybe their algorithms were just not good enough.

Unfortunately I could not try out their algorithms myself. My pictures just finished processing a few days before they announced to close down. But I found a comment of one of the founders on Hacker News, saying that they used a deep convolutional neural network with 3 layers for the semantic image analysis. This is the same technology Google now uses for their photo search.

But they were unhappy with the results of the algorithm so in January this year they changed their approach as their CTO, Kevin Quennesson, explains in ‘To Reclaim Your Photos, Kill the Algorithm’.  He writes: “If a user is a food enthusiast and takes a lot of food close-ups, are we going to tell him that this photo is not the photo of a dish because an algorithm only learned to model some other kind of dishes?” They found that the algorithm’s errors were not comprehensible for the end user.

So they planned to change their system. As I understand it, their old system learned and used concepts independent of the single user. But the new system also uses pictures of the same user to infer the content of a new picture. He calls this “feature based image backlinks”.

Explanation Feature-based Image Backlinks

The graph shows how a picture of a dish can be correctly identified because the content can be inferred by similar pictures of the user that the system identified correctly before. – from Quennesson’s blog post

Regardless of the success of Everpix, I think using the context of an image more is a helpful and necessary approach to build systems, that will reliably predict the content of an image in the future.

In any case I wish we would hear more about the underlying algorithms, what they tried, what worked and what not.

Assumptions about the end user

I am in the middle of a little literature review on using machine learning for photo organisation and came across a statement that struck me as misconceived. The paper’s topic is segmenting photo streams into events and states at the end of page 5:

We believe that for end users, having a low miss rate is more valuable than having a low false alarm rate.

I believe this is a false assumption that will lead to frustrated end users. Out of my own experience I am convinced that the opposite is true.

They continue: “To correct a false alarm is a one-step process of removing the incorrect segment boundary. But to correct a miss, the user must first realize that there is a miss, then figure out the position of the segment boundary.”

Similar to face detection users will be happy about a correct detection but unhappy about an algorithm that creates wrong boundaries they have to manually correct.

And if we assume, that a conservative algorithm still finds all the strong boundaries, the user might not miss the not detected boundaries after all.

Algorithms should not create new work for the user, but remove (some of) it.

Content based image classification with the bag of visual words model in Python

Even with ever growing interest in deep learning I still find myself using the bag of visual word approach, if only to have a familiar baseline to test my new fancy algorithms against. I especially like the BoW demo script from the VLFeat team, that reaches a solid 65% accuracy on the, admittedly outdated, Caltech101 dataset. The script has the advantage that it is contains all the usual steps in one script (feature extraction, training of the classifier and evaluation of the whole pipeline) and that it can also be easily adapted to other datasets.

The only problem was, that it is a Matlab script and Matlab licences are in my experience often scarce due to their high price even for research institutes. So I rewrote the script in Python using the uncomplete VLFeat Python wrapper.

You can find my code as usual on github: https://github.com/shackenberg/phow_caltech101.py

In case you are just diving into the world of BoW I recommend my minimal BoW image classifier code, which might be easier to understand.

How to archive my tweets?

[UPDATE]

So, it looks like IFTTT deleted my recipe, to avoid drawing Twitters wrath on themselves. I will mail the customer support and ask, what happened…

[Original article]

tldr: IFTTT recipe: Archive my tweets to dropbox!

Even though I am a happy Twitter user, it makes me feel very uncomfortable that I cannot easily access all my old tweets. For that reason I used IFTTT and Dropbox for the last several months to archive all the new tweets, so that I have access to those at least. But after Twitter forbid IFTTT to directly access the tweets, this solution was no longer working. But as clever users found out, Twitter is still providing a RSS feed containing all publicly sent tweets  for each user.

As a result it was very easy to get the whole pipe line working again. If you want to try it youself just use my public IFTTT recipe: Archive my tweets to dropbox! You only have to replace my Twitter handle with yours…

Btw: Please share if you have other useful recipes!

International Computer Vision Summer School (ICVSS) 2012, a review

This blog post is intended to be informative for students who plan to attend ICVSS for the first time and to give feedback to the organizers, because I had not time to fill out my feedback-form back there 😉

It is based on my experiences of participating in this years ICVSS 2012. In this post I will only talk about the organizational side. Of course the lectures are the most important part of the summer school, but it is easier to establish if the lectures are relevant to you than to find out if you would enjoy the summer school.

TLDR: I liked it very much. If you are a 2nd or 3rd year PhD student and have 1300€ to spend, definitely go!

What is ICVSS?

The International Computer Vision Summer School is a yearly one-week conference for students in the field of computer vision held in Sicily, Italy. In contrast to normal conferences it is less formal and the aim is to learn rather than to present. For that reason they invited renowned researchers and professors to talk about he “theoretical and practical aspects of real Computer Vision problems as well as examples of their successful commercialisation”.

The summer school’s program comprises of

  • lectures,
  • workshops (which are a like practical lectures),
  • poster presentations by the attendees,
  • a reading group,
  • a essay contest (Brady Price),
  • a written exam and
  • social events.

It is organized by the University of Catania, Sicily, Italy and the University of Cambridge, UK.

The Program

All five days followed roughly the same pattern. They started with breakfast at 8h followed by two lectures before lunch. After lunch there was one more lecture followed by a coffee break. The after-coffee-break program varied throughout the week:

  • The first two days students were presenting their posters,
  • on the third day there was a guided tour to ancient city of Ragusa Ibla,
  • on the fourth day the afternoon was filled with the Reading Group and
  • on the last day Friday, there was the examinations, the student presentations and an award ceremony.

Generally speaking everything was very well organized, even – if you allow me this cliché – from a German point of view. The issues I was told or experienced myself were mostly due to circumstances outside of the ICVSS staff’s influence like airlines or the hotel being sloppy.

In fact all lectures and events were starting so punctual that I had trouble being always punctual 😉

They also managed to give the summer school a nice pace. There was no downtime to get bored and you never had to stress to see or do the things you wanted.

Lectures

My only issue with the program was that the lectures were too long. Some lasted 2h without break. They changed that halfway through the summer school and I hope that sticks for the next years. I would suggest cutting the all lectures into blocks of 50min followed by 10 min breaks.

Poster Sessions

In the poster sessions students could present their work to the other students to get feedback, which is always very valuable as the other participants are from a similar field with out being too familiar to you work to ask the right questions.

The was also a competition for best poster. The two winners received a money price (700€) and were asked to present their work in a short talk on Friday after the examinations. (Congratulations again to Christof Hoppe with Photogrammetric Camera Network Design for Micro Aerial Vehicles)

My only quarrels where that some people did not go to the second floor, because there were not enough signs. Furthermore the rooms were too crowded, especially in the corners where posters were hanging on each side, although there was unused room upstairs in the gallery.

Reading Group and Essay Contest

The aim of the reading group is to teach and practice the skill of reading research papers. To take part you have to prepare a homework “studying (not just reading) one or more topics provided by the school committee, and tracing the ideas as far back as you can.” This year the topic was image features and last year it was shapes. The groups and individuals with the best and most interesting submissions will be asked to present their work during the reading group at the summer school followed by a discussion. The group or the individual with the best presentation is awarded a money price of 1000$. If I remember correctly only 18 groups or individuals participated and you can listen and take part in the discussion even if you haven’t sent in homework. Never the less, I would urge you to hand in something as the organizer of the reading group, Stefano Soatto, give extensive feedback.

The essay contest (also called Brady Price) was about discussing the current and the future “real world” social impact of computer vision technology. There were two topics to choose from (Urban Landscapes and Computer Vision and Medicine) and the two winner were asked to read out their essay and received 600€ in price money.

Exam

The exam consisted of 37 multiple choice questions covering the lectures and workshops. You had to answer 17 correctly to pass the exam and receive a separate certificate. Only a few of the lecturers gave useful example questions after their lectures so we were not really sure what to expect. In the end the questions were quite fair and sensible. I would say, you can pass studying in your room at night if you paid attention in all the lectures.

Social Events

I actually attended my first beach party during the summer school. The other activities were also very enjoyable. Look forward to them.

Venue, Accommodation and Food.

When I told my friends about the summer school I found myself using the following phrase a lot:

It was the nicest prison I have ever stayed in.

Maybe I am just not used to resort vacation, but I think this description fits. The hotel is remote and you wont be able to leave the place and find anything in walking distance except for a small fishing village and a beach.

Nevertheless I liked the place, as it provides everything one needs. I even was able to buy some swimming pants and flip-flops I forgot back in Germany.

For each meal the hotel would provide a varied buffet and I can’t remember anyone complaining about the food. If you are vegetarian it is definitely doable without starving taste-buds.

Internet

The internet connection was bad! Very bad!! In theory there was WiFi in the lobby of the hotel, the lecture hall and in the foyer of the lecture hall, where the organizers have their temporary office. (Note: No WiFi in the rooms!)

But in practice the WiFi connections were so slow that sometimes not even emails would load and there was a connection timeout of like 5 mins after which one had to re-enter a personal code of nearly 20 characters, which made using the internet on the phone way more annoying than fun. As I wrote the resort is very remote, so it is probably cost prohibitive to get faster internet for the few internet addicts visiting once a year. Which is a pity as the organizers try to push the use of social media (facebook/twitter) during the conference, which is imho a fun idea. But my proposal would be to shut off the WiFi in the lecture hall. As a result, people are less tempted (and less frustrated) by the internet during the talks and there would be more bandwidth left for the people sitting in the foyer (doing important stuff ™)

Money

If you coming from Europe this summer school will cost you roughly 1650€. (600€ for the school, 750€ for a single room and 300€ for the flight.  You can cut the costs to 1250€ by reserving a bed in a 4 person room (450€) and by booking your flight early with websites like skyscanner.com.  This is still quite expensive, but I was quite satisfied in the end. There were no hidden costs, they didn’t seem to throw out money for totally unnecessary things and they didn’t try to sell things, which I cannot stress enough.

More warning than recommendation is this résumé by Roman Shapovalov, who choose a hotel in the near village to stay for ICVSS 2010.

People

As the organizers told us in the opening presentation, the most important part of this conference are the people we meet. For some working on their own at their home universities this might be a first time to feel as part of a community. And the process of becoming a community is deliberately amplified by the choice of such a remote venue. For every meal and for every activity we stayed together, so you got to know the other people very fast.

Also most of the lecturers stay for more than a day, so this was a great chance to interact with them in a very relaxed environment. Some even brought their families, which shows how much they enjoy this summer school themselves.

Summary

I liked it a lot and I think I will go again. If not next year, in 2014, even though I will have to pay it from my student scholarship. I’ll be probably booking a bed in a four-person room, which makes it cheaper and more interactive.

My recommendation is to go as soon as you finished your literature review and have a some results to present. Make sure you have something to show and talk about. Than you can learn and profit from the connections you make and the tips you receive a long time.

There is also the CVML Summer Schools organized by INRIA, France, which ended this year just before ICVSS. If you have enough money then go to both, otherwise choose with regard to the speakers.

Tipps

  • Prepare an elevator speech
  • Leave your notebook at home. Remember there is no internet and you are there to meet people. You can bring yours slides on a USB stick if you are planning on winning the competition.
  • Don’t go to bed too early, sleep after lunch. You don’t miss anything and it is too hot to do anything anyway.
  • Plan one or two days of extra stay in Sicily. It is easier to ignore the beach next to the hotel, when you know you have time afterwards to go to the beach – you pay for the return flight anyway! My recommendations would be Siracusa and Stromboli.
  • Don’t forget your swimming pants! You need them and they are expensive in the resort.

Further reading:

Did you attend ICVSS? What was your experience?
Thinking about going and having questions left?
Leave a comment!

[update] corrected breakfast time and modified intro

Book: Programming Computer Vision with Python

Book cover: Programming Computer Vision with Python

In case anyone missed it, you can download a very mature draft of “Programming Computer Vision with Python” at programmingcomputervision.com. This book takes a fresh approach at introducing people to the computer vision field. It is aimed at beginners, who have some programming experience (not necessary Python) and basic understanding of linear algebra (matrices and vectors) and analysis.

The covered topics are (as taken from the TOC):

  • Basic Image Handling and Processing
  • Local Image Descriptors
  • Image to Image Mappings
  • Camera Models and Augmented Reality
  • Clustering Images
  • Searching Images
  • Classifying Image Content
  • Image Segmentation
  • OpenCV

What I like the most are the mini project like programming your own little augmented reality app or building a complete web app for content based image search. It is always great to have little working demos to show to your friends. I will definitely recommend it to anyone new and interested in the computer vision field.

The author, Jan Erik Solem, is Associate Professor at Lunds Universitet and co-founder of PolarRose, a facial recognition software company which was bought by Apple in September 2010.

You can buy the book from July on at Amazon.com or download, as said, the draft from the book’s website.

How good is Google Drive’s image recognition engine?

As announced via twitter I took the time to test Google Drive’s image recognition feature. Google Drive was announced two weeks ago with a blog post, which contained the bold claim:

Search everything. Search by keyword and filter by file type, owner and more. … We also use image recognition so that if you drag and drop photos from your Grand Canyon trip into Drive, you can later search for [grand canyon] and photos of its gorges should pop up. This technology is still in its early stages, and we expect it to get better over time.

This sparked my curiosity, so I evaluated Google Drive’s performance like I would with the image recognition frameworks I do my research on. First I uploaded an image dataset and with images containing known objects and then counted how many of the pictures Google Drive’s search would find, if I search for these objects.

As dataset I used the popular  Caltech 101 dataset containing pictures of objects belonging to 101 different categories. There are about 40 to 800 images per category and roughly 4500 images in total. While being far from perfect, it is a well-known contender.

These are my first finding:

  • Google Drive only finds a fraction of the images, but the images it finds it categorizes correctly.

  • In numbers: Precision is 83% (std=36%) and the recall is 8% (std=11%) (averaged over all categories)
  • The best results it achieves for the two ‘comic’ categories ‘Snoopy’ and ‘Garfield’ and for iconic symbols like the dollar bill and the stop sign.
  • As the The Caltech 101 dataset was created using Google’s image search the high precision is at least partly a result of a ‘simple’ duplicate detection with the Google index and not of a successful similarity search.

Verdict:

As all vision systems working in such an unconstrained environment they are far from being actually usable. One cannot rely on them, but once or twice they will surprise you by adding an image to the result list, that one hasn’t thought of.

Further resources:

[update]

Link to Matlab code which achieves 65% precision with 100% recall.*

* The numbers are not comparable 1-to-1 as both use a different evaluation approach. The Matlab script assigns to each image of the dataset its most likely class, while google drive tries to find a concept or object in the image.