Exemple #1
0
def mk_final_pred_item():
    CHECKPOINT_SAVE_PATH = os.path.join(os.path.dirname(__file__), os.pardir, 'model_checkpoints')
    tf.reset_default_graph()
    # used to map the output from the prediction to the emotion class
    X = tf.placeholder(
        tf.float32, shape=[None, 48, 48, 3]
    )
    keep_prob = tf.placeholder(tf.float32)
    y_conv = model(X, keep_prob)
    with tf.Session(config=config) as sess:
        saver = tf.train.Saver()
        saver.restore(sess, os.path.join(CHECKPOINT_SAVE_PATH, 'model.ckpt'))
        name_item = from_cam(sess,X,y_conv,keep_prob)
        print(name_item)
    return name_item
Exemple #2
0
    files = glob.glob(emoji_png_files_path)

    logger.info('loading the emoji png files in memory ...')

    import platform

    if platform.system() == 'Windows':
        split_string = '\\'
    else:
        split_string = '/'

    for file in tqdm.tqdm(files):
        logger.debug('file path: {}'.format(file))
        emoji_to_pic[file.split(split_string)[-1].split('.')[0]] = cv2.imread(
            file, -1)

    X = tf.placeholder(tf.float32, shape=[None, 48, 48, 1])

    keep_prob = tf.placeholder(tf.float32)

    y_conv = model(X, keep_prob)

    saver = tf.train.Saver()

    with tf.Session(config=config) as sess:
        saver.restore(sess, os.path.join(CHECKPOINT_SAVE_PATH, 'model.ckpt'))

        logger.info('Opening the camera for getting the video feed ...')
        logger.info('PRESS "q" AT ANY TIME TO EXIT!')
        from_cam(sess)