Ask Your Question
0

CSV File for Yale Faces

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

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 create_csv.py script provided in contrib/doc/facerec/src

edit retag flag offensive close merge delete

Comments

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 -0600 )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 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
1

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

berak gravatar image

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

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 "create_csv.py 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 : yale.py /absolute/path/to/folder/with/yale/images > yale.csv

whatever you choose, the outcome should look like this:

...
E:\MEDIA\faces\yalefaces\png\subject10.surprised.png;9
E:\MEDIA\faces\yalefaces\png\subject10.wink.png;9
E:\MEDIA\faces\yalefaces\png\subject11.centerlight.png;10
E:\MEDIA\faces\yalefaces\png\subject11.glasses.png;10
E:\MEDIA\faces\yalefaces\png\subject11.happy.png;10
...

(per line: absolute_path semicolon id)

edit flag offensive delete link more

Comments

I decided to put the files in subject-specific directories and use the unmodified create_csv.py. 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 -0600 )edit

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

berak gravatar imageberak ( 2013-11-28 02:23:22 -0600 )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 -0600 )edit

(os.walk probably sorts by creation date)

all true, but does it matter ?

berak gravatar imageberak ( 2013-11-29 15:02:09 -0600 )edit

Question Tools

Stats

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

Seen: 735 times

Last updated: Nov 27 '13