Ask Your Question

CSV File for Yale Faces

asked 2013-11-26 18:10:21 -0500

xaffeine gravatar image

I am working through the example for face recognition and I would like to use the Yale database for training and comparing various recognizers. Has anyone got a CSV file to use with that database? Or would I have to create it myself?

I guess I would do it by moving the files into subject-specific folders and then running the script provided in contrib/doc/facerec/src

edit retag flag offensive close merge delete


It's weird that we call these files "CSV" files. They are not comma-separated and can not be interpreted by typical csv-reading software. Nothing wrong with this format, of course, it's just wrong to call it csv.

xaffeine gravatar imagexaffeine ( 2013-11-27 13:15:19 -0500 )edit

yea, you're right about this.

again, let's keep it straight:

  • you'll need a vector<Mat> of (one row per sample(img), and a Mat(1 row for each label) [labels] to make it happen.
  • the csv approach is just one way to make it happen. hey have no fear to break it, if it does not suit your needs
berak gravatar imageberak ( 2013-11-27 13:24:49 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2013-11-27 02:35:25 -0500

berak gravatar image

updated 2013-11-27 02:56:50 -0500

iirc, the yale db comes as 'gif' images, which arent readable by imread(), so you'd have to batch-convert them to png first

also, the yale db does not come with one folder per person,

so either make folders for each, then run " folder_with_yale_images"

or try this:

import os,sys

id = -1
pn = ""
for dirname, dirnames, filenames in os.walk(sys.argv[1]):
    for filename in filenames:
        p = filename.split(".")
        if p[0] != pn:
            id += 1
            pn = p[0]
        src = os.path.join(dirname, filename)
        print "%s;%d" % (src, id)

# run : /absolute/path/to/folder/with/yale/images > yale.csv

whatever you choose, the outcome should look like this:


(per line: absolute_path semicolon id)

edit flag offensive delete link more


I decided to put the files in subject-specific directories and use the unmodified First, I used Irfanview to batch-convert to png. Funny thing, the os.walk enumerated dirs in a strange order (on Windows), but it still works.

xaffeine gravatar imagexaffeine ( 2013-11-27 13:13:09 -0500 )edit

oh, os.walk does not sort by name, right ?

berak gravatar imageberak ( 2013-11-28 02:23:22 -0500 )edit

Officially, it is in arbitrary order. Might be good to use for filename in sorted(filenames)

xaffeine gravatar imagexaffeine ( 2013-11-29 14:41:39 -0500 )edit

(os.walk probably sorts by creation date)

all true, but does it matter ?

berak gravatar imageberak ( 2013-11-29 15:02:09 -0500 )edit
Login/Signup to Answer

Question Tools


Asked: 2013-11-26 18:10:21 -0500

Seen: 558 times

Last updated: Nov 27 '13