示例#1
0
 def get_count(self, sf, ROI, CPI, parameters):
     glint_CPI = copy.deepcopy(CPI)
     preprocess_glint = preprocess(None, sf, glint_CPI, parameters['blur'],
                                   parameters['canny'])
     self.H_count = preprocess_glint.g_count(ROI, glint_CPI, parameters,
                                             self.Video)
示例#2
0
 def get_blur(self, sf, CPI, parameters, ROI_pupil, ROI_glint):
     pre_pupil_blur = preprocess(None, sf, CPI, parameters['blur'],
                                 parameters['canny'])
     self.pupil_blur = pre_pupil_blur.anal_blur(ROI_pupil, ROI_glint,
                                                self.Video)
示例#3
0
 def glint_threshold(self, center, sf, CPI, parameters):
     pre_glint_threshold = preprocess(center, sf, CPI, parameters['blur'],
                                      parameters['canny'])
     return pre_glint_threshold.d_glint()
示例#4
0
 def pupil_threshold(self, center, sf, CPI, parameters):
     pre_pupil_threshold = preprocess(center, sf, CPI, parameters['blur'],
                                      parameters['canny'])
     return pre_pupil_threshold.start()
示例#5
0
import fileUtils as fu

import logger as lg

parser = argparse.ArgumentParser()
parser.add_argument('-d', '--dset')
parser.add_argument('-a', '--algo')
# parser.add_argument('-r', action='store_true')
args = parser.parse_args()

cfg.config(args.dset, args.algo)
# cfg.config('energydata_complete')
# cfg.config('peugeot_207_01')
lg.initLogger(cfg.ds_name, cfg.algo)

X, y = pp.preprocess('../datasets/' + cfg.ds_name + '.csv', cfg.delimiter, cfg.skiprows, cfg.endColumn, startColumn= cfg.startColumn, targetColumn = cfg.targetColumn, pca = cfg.pca, decimal = cfg.decimal) 
train_size = None
if cfg.algo.lower() == 'k-nn':
    if cfg.training_set_cap != None:
        if X.shape[0] * (1 - cfg.test_size) > cfg.training_set_cap:
            train_size = cfg.training_set_cap / X.shape[0]
X_train, X_test, y_train, y_test = train_test_split(X, y, train_size=train_size, test_size=cfg.test_size, random_state=1)

fu.cleanSIDirs('./out/')

if cfg.algo.lower() == 'ann':
    import ANN as ann
    ann.process(X_train, X_test, y_train, y_test)      
elif cfg.algo.lower() == 'k-nn':
    import KNN as knn
    knn.process(X_train, X_test, y_train, y_test)
示例#6
0
model = crnn.CRNN(32, 1, 37, 256)
if torch.cuda.is_available():
    model = model.cuda()
print('loading pretrained model from %s' % model_path)
model.load_state_dict(torch.load(model_path))

alphabet = '012345678946066796176100049157000462'
converter = utils.strLabelConverter(alphabet)

transformer = dataset.resizeNormalize((100, 32))

path = input("Enter the path:")
for i in os.listdir(path):
    img_path = path + '/' + i
    image = preprocess(img_path)
    image = Image.open(img_path).convert('L')
    image = transformer(image)
    if torch.cuda.is_available():
        image = image.cuda()
    image = image.view(1, *image.size())
    image = Variable(image)

    model.eval()
    preds = model(image)

    _, preds = preds.max(2)
    preds = preds.transpose(1, 0).contiguous().view(-1)

    preds_size = Variable(torch.IntTensor([preds.size(0)]))
    sim_pred = converter.decode(preds.data, preds_size.data, raw=False)