Exemple #1
0
def updateEntryTimeTable(entry):
	bracList = []
	if entry['type'] == 'dir':
		if entry['recursive']:
			bracs = common.locate('*.brac', entry['path'])
		elif not entry['recursive']:
			bracs = glob.glob(os.path.join(entry['path'], '*.brac'))
		for f in bracs:
			if f not in bracList:
				bracList.append(f)
		
	elif entry['type'] == 'file':
		if entry['path'][-4:].lower() == 'brac' and entry['path'] not in bracList:
			bracList.append(entry['path'])
	
	entry['bracList'] = []
	for b in bracList:
		timetbl = getBracTimeTable(b)
		entry['bracList'].append({
			'path': b,
			'mtime': os.path.getmtime(b),
			'timetable': timetbl,
		})

	if entry['type'] == 'dir':
		entry['subdirs'] = {}
		subdirs = common.subdirs(entry['path'])
		for sd in subdirs:
			entry['subdirs'][sd] = os.path.getmtime(sd)
		
	entry['mtime'] = os.path.getmtime(entry['path'])
Exemple #2
0
def updateEntryTimeTable(entry):
    bracList = []
    if entry['type'] == 'dir':
        if entry['recursive']:
            bracs = common.locate('*.brac', entry['path'])
        elif not entry['recursive']:
            bracs = glob.glob(os.path.join(entry['path'], '*.brac'))
        for f in bracs:
            if f not in bracList:
                bracList.append(f)

    elif entry['type'] == 'file':
        if entry['path'][-4:].lower(
        ) == 'brac' and entry['path'] not in bracList:
            bracList.append(entry['path'])

    entry['bracList'] = []
    for b in bracList:
        timetbl = getBracTimeTable(b)
        entry['bracList'].append({
            'path': b,
            'mtime': os.path.getmtime(b),
            'timetable': timetbl,
        })

    if entry['type'] == 'dir':
        entry['subdirs'] = {}
        subdirs = common.subdirs(entry['path'])
        for sd in subdirs:
            entry['subdirs'][sd] = os.path.getmtime(sd)

    entry['mtime'] = os.path.getmtime(entry['path'])
Exemple #3
0
 def register_inheritors(self, property, root_path, base_type, lifestyle_type = "UNKNOWN", include_base = False):
     if (lifestyle_type == "UNKNOWN"): lifestyle_type = self.default_lifestyle_type
     self.assert_valid_lifestyle_type(lifestyle_type)        
     
     all_classes = []
     
     for module_path in common.locate("*.py", root=root_path, recursive=False):
         module = reflection.get_module_from_path(module_path)
         classes = reflection.get_classes_for_module(module)
         
         for cls in classes:
             should_include = include_base and cls.__name__ == base_type.__name__
             should_include = should_include or (cls.__bases__ is (list, tuple) and base_type.__name__ in [klass.__name__ for klass in cls.__bases__])
             if should_include:
                 all_classes.append(cls)
     
     component_definition = "indirect", lifestyle_type, all_classes, None, None
Exemple #4
0
 def register_inheritors(self, property, root_path, base_type, lifestyle_type = "UNKNOWN", include_base = False):
     if (lifestyle_type == "UNKNOWN"): lifestyle_type = self.default_lifestyle_type
     self.assert_valid_lifestyle_type(lifestyle_type)        
     
     all_classes = []
     
     for module_path in common.locate("*.py", root=root_path, recursive=False):
         try:
             module = reflection.get_module_from_path(module_path)
         except UnicodeDecodeError, err:
             print err
             raise
         classes = reflection.get_classes_for_module(module)
         
         for cls in classes:
             should_include = include_base and cls.__name__ == base_type.__name__
             should_include = should_include or (isinstance(cls.__bases__, (list, tuple)) and base_type.__name__ in [klass.__name__.replace("__init__.","") for klass in cls.__bases__])
             if should_include:
Exemple #5
0
 def register_files(self, property, root_path, pattern, lifestyle_type = "UNKNOWN"):
     if (lifestyle_type == "UNKNOWN"): lifestyle_type = self.default_lifestyle_type
     self.assert_valid_lifestyle_type(lifestyle_type)        
     
     all_classes = []
     for module_path in common.locate(pattern, root=root_path):
         module = reflection.get_module_from_path(module_path)
         
         class_name = common.camel_case(module.__name__)
         cls = reflection.get_class_for_module(module, class_name)
         
         if cls == None:
             raise AttributeError("The class %s could not be found in file %s. Please make sure that the class has the same name as the file, but Camel Cased." % (class_name, module_path))
         
         all_classes.append(cls)
     
     component_definition = "indirect", lifestyle_type, all_classes, None, None
     self.components[property] = component_definition
Exemple #6
0
    print('idx {}'.format(idx))
    idx += 1
    img = tf.io.read_file(p + '/img.png')
    img = tf.image.decode_jpeg(img, channels=3)
    img = tf.image.resize(img, [width, height])
    raw_img = img
    img = img / 255.0

    result = detect_model.predict(np.array([img]))

    mask = create_mask(result)
    mask = tf.keras.preprocessing.image.array_to_img(mask)
    mask = np.asarray(mask)
    img = np.asarray(img)

    plate_image = locate(img, mask)
    plate_chars = recognition_model.predict(np.array([plate_image]))
    plate = []
    for cs in plate_chars:
        plate.append(index_to_char[np.argmax(cs)])

    real_plate = pathlib.Path(p).name
    predict_plate = ''.join(plate)

    if predict_plate != real_plate:
        print('wrong real plate is {}, predict plate is {}'.format(
            real_plate, predict_plate))
        error_count += 1
        raw_img = np.asarray(raw_img)
        plate_image = locate(raw_img, mask)
        tf.io.write_file('./dataset/error/' + real_plate + '/plate.jpeg',