Tuesday, September 1, 2009

Face recognition in Adobe Photoshop Lightroom or Apple's Aperture to tag yours photos ?



It is quite known that, as of today, there is no face recognition technology embedded into Adobe Photoshop Lightroom and that's a shame ! If you can't wait for Adobe to include this in a future version of the software... keep reading.


This is a Mac user only trick (but you can adpat to whatever you want with a little creativity) and although this is really not difficult, this not a pretty way of giving face recognition to Adobe Lightroom. First what is face recognition ? Well, it is a technology that helps you when tagging (or keywording) your photos. When you have a lot of photos of people, you almost always want to find out all the photos of a given relative/friend/whoever. One way to do this is to add a keyword (tag) to each photo by hand in Lightroom or other software. This approach is a nightmare ! Face recognition is another way. Usually, you tag a few photos of a person and the face recognition software gets you several others pictures that might have that person. You can correct the soft if it is wrong and so on. The more you tag and the more the soft gets good at recognizing people. This is great. One soft that does this beautifully is Apple's iPhoto 2009. iPhoto 2009 comes free with every new Mac and as part of iLife 2009 for a few bucks otherwise.

The main idea here is to use Apple iPhoto's face recognition technology to tag the photos in Lightroom (or other soft) without going too much into iPhoto. Here's what we'll need:
-iPhoto 2009 (free with every new Mac),
-ExifTool for Mac, free, download and install,
-A script written by Andrew Turner found here,
-Lightroom (or other). I will assume Lightroom below.

This has only been tested with Mac OS X Leopard (don't know if it works in Snow Leopard, Tiger or elsewhere, test it and tell us).

Then, the first thing you should do is backup your photos. There is no danger here but in case the final tags are not what you expect, you should be careful.

Here are the steps:
-Open iPhoto 2009 and go to iPhoto-->Preferences-->Advanced and uncheck the Copy items to iPhoto Library option. This will prevent iPhoto from physically importing your photos and save space on your drive,
-Go get some photos and drop them into iPhoto. As an example, I will assume that you are tagging a bunch of photo with friends and Barack Obama !
-Use iPhoto 2009's face tagging to tag the faces in your newly imported pics. This is quite simple, just select a picture and click the Name button. If you are not sure about this, just look at this video.
-Now this is where things gets tricky. When you tag faces in iPhoto, the tags are in fact not added to the photos themselves. Modern photo formats such as JPEG have Metadata information that can save many information such as camera type, day, time, etc. Metadata can also save keywords and tags. Well known metadata format are EXIF or IPTC. iPhoto tags does NOT end up in any of those Metadata but are saved elsewhere. This is precisely what we need to circumvent.
-To do that, once you face tagged everything you needed, just go to iPhoto's Faces directory in the left pane. There you should see a framed picture of every person you named. Double click the frame with Obama's name, iPhoto displays every picture with Obama in thumbnails. We will now explicitely retag the pictures. In iPhoto's View menu, check Keywords (or press Shift+CMD+K) to activate keywords. This should display a space below every picture that says something like Add Keywords. Click that area below one of the pictures and add the name of the person between double quotes. For instance here "Barack Obama". The quotes are important. Now select all the pictures of the person. For some reason, you can not CMD+A... So what I do is reduce the size of the thumbnails using the size scroller on bottom left and then select every picture with the mouse. Now that every picture is selected, in iPhoto's Window press Show Keywords (or type CMD+K). This should bring a dialog with previously used keywords. As you just keyworded one photo of the person with his name, this keywords should be in the list. Just click it (in the example you should click Barack Obama). This will give every picture you selected, and that hopefully have the person's face in them, a keyword with his name. Fine !
-Now assuming that you already installed ExifTool, we will run the script you downloaded. First in iPhoto make sure that every photo we retagged in the previous step are selected. Unzip the script and double click it. It should open in Script Editor (you can change the Copyright property in the script code to append yours). Click the Execute button. This should bring iPhoto into focus and depending on the number of photos... take some time. This script uses ExifTool to write into each photo's IPTC metadata, the information that is written in iPhoto's keyword space. As we've only put the name of the person in this place, it will write only the name. (To be exact, it will also overwrite the IPTC copyright tag, that's why I suggested you should put your copyright notice in the script's code in the line that says property copyright : "©. All Rights Reserved." )
-Once the script is done, it will display a message that should say Exif writing complete. Please be patient. Now your photos of Barack Obama are tagged and ready for Lightroom. Import them into Lightroom, they should be tagged ! Do a search (by keyword) for Obama and all the photos with Obama's face should appear.

Neat ! However one point is annoying if you already have many tagged photos in Lightroom. As iPhoto, it appears that Lightroom's tags are separate from Metadata. When you import a new photo to Lightroom, it will read the metadata and extract keywords, that's what we used ! However, if you have already tagged photos, you will need to reimport the metadata* and it appears that it would erase current keywords in Lightroom... at least that's the message Lightroom displays.

Enjoy and comment !

*To reimport metadata in Lightroom, right click a photo in the library and you should see a metadata option in the contextual menu. You can right click a bunch of them.

If you found this post useful, you can buy me a coffee or two... Just click the coffee cup below ;-) Thanks a lot !!








1 comments:

cloveras said...

Thanks! Quite a few extra steps in the workflow, but god to know that it is possible with some effort. Of course, Aperture 3 does face recognition very elegantly. I hope Adobe adds something similar to Lightroom 3.