Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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

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)

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
/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)

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("_")
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
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)