Ejemplo n.º 1
0
    def register(self, data_path):
        """Register a group of people specified in data folder and train

            Args:
                data_path (string): train data folder
        """
        if data_path == 'default':
            data_path = Utilities.train_data_path()
        if Utilities.file_exists(data_path):
            group = ModelFactory.registered_group()
            group.save()
            for alias_name in os.listdir(data_path):
                # Ignore gitkeep file and collect data from all folders
                if alias_name != '.gitkeep':
                    logger.log('Registering %s...' % alias_name)
                    Person.register(group, alias_name)
            # After everything is done, call api to train newly created group
            self.train()
Ejemplo n.º 2
0
    def register(group, alias):
        data_path = Utilities.absolute_path(Utilities.train_data_path(), alias)

        with open(os.path.join(data_path, 'name.txt'), 'r') as file:
            name = file.read()
            person = group.person_with_name(name)
            person.alias = alias
            create_voice_thread = threading.Thread(
                name="create_voice",
                target=Person.__create_voice,
                args=(name, alias))
            person.save()

            save_faces_thread = threading.Thread(name="save_faces",
                                                 target=Person.__save_faces,
                                                 args=(person, data_path))

            processes = ProcessParallel(create_voice_thread, save_faces_thread)
            processes.fork_threads()
            processes.start_all()
            # Wait until all threads are done
            processes.join_all()