コード例 #1
0
    def __init__(self):

        self.CONF = 0.7

        self.classifier = classify.Classify()
        self.preprocessor = preprocess.PreProcessor()
        self.class_names = self.classifier.get_class_names()
        self.cache = cache.Cache(max_size=10)

        self.faceCascade = cv2.CascadeClassifier(
            'haarcascade_frontalface_default.xml')
コード例 #2
0
ファイル: main.py プロジェクト: RyanGoslingsBugle/decrank
def process(df, frac_str, type_str, dimensions, balance=True):
    """
    Apply data transformations/dimensionality reduction
    :param frac_str: string denoting percentage of dataset operated on
    :param dimensions: List of int values to reduce dimensions to
    :param balance: Boolean apply class re-sampling to resolve imbalance
    :type df: Pandas dataframe
    :type type_str: training or test data label
    """
    preprocessor = preprocess.PreProcessor()
    data_arr, labels = do_transforms(df, type_str, frac_str, preprocessor)

    for dimension in dimensions:
        print("Applying dimensionality reduction...")
        data_lsa = preprocessor.truncate(data_arr, dimension)
        print("Reduction produced a: {}".format(type(data_lsa)))
        print("With shape: {}".format(data_lsa.shape))

        print("Saving reduced data...")
        joblib.dump(data_lsa,
                    'data/{}/{}-data-dm-{}.gz'.format(frac_str, type_str,
                                                      dimension),
                    compress=3)
        del data_lsa

    del data_arr

    if balance:
        for dimension in dimensions:
            print("Applying class re-sampling to array with dimensions: {}...".
                  format(dimension))
            data_arr = joblib.load('data/{}/{}-data-dm-{}.gz'.format(
                frac_str, type_str, dimension))
            data_rs, label_rs = preprocessor.balance(data_arr, labels)
            print("Re-sampling produced a: {}".format(type(data_rs)))
            print("With shape: {}".format(data_rs.shape))
            print("Label shape: {}".format(label_rs.shape))

            print("Saving prepared data...")
            joblib.dump(data_rs,
                        'data/{}/{}-data-rs-{}.gz'.format(
                            frac_str, type_str, dimension),
                        compress=3)
            joblib.dump(label_rs,
                        'data/{}/{}-label-rs-{}.gz'.format(
                            frac_str, type_str, dimension),
                        compress=3)
            del data_rs, label_rs
コード例 #3
0
ファイル: main.py プロジェクト: AnujDawar/face-authenication
import classify
import sys
import cv2
import preprocess
import time

classifier = classify.Classify()
preprocessor = preprocess.PreProcessor()

camera = cv2.VideoCapture(0)
i = 0;
start = time.time()

prediction_out_dir = "prediction_output_images/"

print("start_time ", start)

while True:
    return_value, image = camera.read()
    # print("time new capture:", time.asctime( time.localtime(time.time()) ))
    # cv2.imwrite('opencv'+str(i)+'.png', image)			commented by anuj
    cv2.imwrite(prediction_out_dir + 'opencv.png', image)
    # print("time image written:", time.asctime( time.localtime(time.time()) ))
    # bb = (preprocessor.align('opencv'+str(i)+'.png'))		commented by anuj
    bb = (preprocessor.align(prediction_out_dir + 'opencv.png'))
    # print("time alignment done: ", time.asctime( time.localtime(time.time()) ))

    if bb.any() == False:
    	pass
    else:
    	cv2.rectangle(image, (bb[0],bb[1]), (bb[2],bb[3]), (0, 255, 0), 5)