def __init__(self, directory, filepath, image_size):
"""
Constructor for an JAFFEInstance object.
Args:
directory (str): Base directory where the example lives.
filename (str): The name of the file of the example.
image_size (tuple<int>): Size to resize the image to.
"""
filename = filepath.split('/')[-1]
self.image = misc.imread( os.path.join(directory, filepath) )
# some of the jaffe images are 3-channel greyscale, some are 1-channel!
self.image = np.atleast_3d(self.image)[...,0] # make image 2d for sure
# Resize and scale values to [0 1]
self.image = misc.imresize( self.image, image_size )
self.image = self.image / 255.0
ident, _, N, _ = filename.split('.')
# Note: the emotion encoded in the filename is the dominant
# scoring emotion, but we ignore this and use precise emotion scores
# from the semantic ratings table
self.identity, self.N = ident, int(N) - 1 # 0-based instance numbering
评论列表
文章目录