Esempio n. 1
0
# construct the argument parser and parse the arguments
ap = argparse.ArgumentParser()
ap.add_argument('-s',
                '--size',
                type=int,
                default=128,
                help='desired size of the image')
args = vars(ap.parse_args())

# grab the list of images
print('[INFO] loading images...')
imagePaths = glob.glob('/home/stu15/s15/ts6442/Capstone/images/images/*.jpg')

# Resize the image keeping aspect ratio in mind
aap = AspectAwarePreprocessor(args['size'], args['size'])
# Resize the image without aspect ratio in mind
# sp = SimplePreprocessor(128, 128)
# converting images to array for easier processing
iap = ImageToArrayPreprocessor()

# load the dataset from disk then scale the raw pixel intensities to the range [0, 1]
sdl = SimpleDatasetLoader(preprocessors=[aap, iap])
# as there are no labels using '_' in place of labels
(data, _) = sdl.load(imagePaths, verbose=1000)
data = data.astype('float') / 255.0
print('[INFO] total number of images are ', len(imagePaths))

(trainX, testX, _, _) = train_test_split(data, _, test_size=0.1)
print('[INFO] train and test split created...')
print(trainX.shape)
Esempio n. 2
0
images = []
labels = []
i = 0
sid = 0
# defining classes as dictionary
emotions = {'No': 0, 'Yes': 1}
for item in image:
    # getting label corresponding to the image
    a = data['Answer.Q1Answer'].loc[
        data['Input.image_url'] ==
        'https://lijingyang.me/images/AmazonMTurk/' + item.split('/')[-1]]
    try:
        # removing more than one entry
        image = cv2.imread('/home/stu15/s15/ts6442/Capstone/Labelled_images/' +
                           item.split('/')[-1])
        ap = AspectAwarePreprocessor(128, 128)
        image = ap.preprocess(image)
        image = img_to_array(image)
        b = a.values.tolist()[0].split('|')[0]
        images.append(image)
        labels.append(emotions[b])
        sid += 1
    except:
        # deleting files with label as "NaN"
        # os.remove('/home/stu15/s15/ts6442/Capstone/Labelled_images/' + item.split('/')[-1])
        i += 1
        print('[INFO] Exception at image number', sid)
        pass
    if sid % 500 == 0:
        print('[INFO] {} images loaded...'.format(sid))
'''
Esempio n. 3
0
ap.add_argument(
    '-p',
    '--path',
    help='path to the saved model',
    default='/home/stu15/s15/ts6442/Capstone/codes/third_model_final.h5')
args = vars(ap.parse_args())

model = load_model(args['path'])
model.summary()

# grab the list of images
print('[INFO] loading images...')
imagePaths = glob.glob('/home/stu15/s15/ts6442/Capstone/images/images/*.jpg')

# Resize the image keeping aspect ratio in mind
aap = AspectAwarePreprocessor(128, 128)
# Resize the image without aspect ratio in mind
# sp = SimplePreprocessor(128, 128)
# converting images to array for easier processing
iap = ImageToArrayPreprocessor()

# load the dataset from disk then scale the raw pixel intensities to the range [0, 1]
sdl = SimpleDatasetLoader(preprocessors=[aap, iap])
# as there are no labels using '_' in place of labels
(data, _) = sdl.load(imagePaths, verbose=1000)
data = data.astype('float') / 255.0
print('[INFO] total number of images are ', len(data))
print('Shape of data is', data.shape)

(trainX, testX, _, _) = train_test_split(data, _, test_size=0.05)
print('[INFO] train and test split created...')