Beispiel #1
0
def run():
    """
    Prepares and runs the whole system.
    """
    args = parse_args()

    logger = logging.getLogger("brc")
    logger.setLevel(logging.INFO)
    formatter = logging.Formatter(
        '%(asctime)s - %(name)s - %(levelname)s - %(message)s')
    if args.log_path:
        file_handler = logging.FileHandler(args.log_path)
        file_handler.setLevel(logging.INFO)
        file_handler.setFormatter(formatter)
        logger.addHandler(file_handler)
    else:
        console_handler = logging.StreamHandler()
        console_handler.setLevel(logging.INFO)
        console_handler.setFormatter(formatter)
        logger.addHandler(console_handler)

# string=",".join([g_num for g_num in args.gpus])
# os.environ["CUDA_DEVICE_ORDER"] = "PCI_BUS_ID"
# os.environ["CUDA_VISIBLE_DEVICES"] = string
    logger.info('Running with args : {}'.format(args))
    if args.prepare:
        prepare(args)
    if args.train:
        train(args)
    if args.evaluate:
        evaluate(args)
    if args.predict:
        predict(args)
    def test_login_legal_user_not_from_training_set(self, mock_record):
        if not self.check_files_exist():
            prepare()

        users = get_users()
        speaker_file = join(users[0], listdir(users[0])[-1])
        mock_record.return_value = wavfile.read(speaker_file)
        self.assertTrue(login_user())
    def test_login_illegal_user_not_from_training_set(self, mock_record):
        if not self.check_files_exist():
            prepare()

        users = get_users()
        illegal_user = '******'
        self.assertFalse(illegal_user in users)
        mock_record.return_value = wavfile.read(join(illegal_user, 'ru_0014.wav'))
        self.assertFalse(login_user())
    def test_login_unknown_illegal_user(self, mock_record):
        if not self.check_files_exist():
            prepare()

        users = get_users()
        illegal_user = '******'
        self.assertFalse(illegal_user in users)
        mock_record.return_value = wavfile.read(join(illegal_user, 'ru_0042.wav'))
        self.assertFalse(login_user())
    def test_register_existed_user(self):
        if not self.check_files_exist():
            prepare()

        users = get_users()
        first_users_len = len(users)
        nickname = users[0]

        self.assertFalse(register_user(nickname))

        users = get_users()
        self.assertEqual(len(users), first_users_len)
    def test_prepare(self):
        for file in self.files:
            if os.path.isfile(file):
                os.remove(file)

        prepare()

        for file in self.files:
            self.assertTrue(pathlib.Path(file).is_file())

        users = get_users()
        self.assertTrue(len(users) > 0)
    def test_register_new_user(self, mock_record):
        prepare()

        users = get_users()
        first_users_len = len(users)
        new_user = '******'
        mock_record.return_value = wavfile.read('speakers/liza_register.wav')

        self.assertFalse(new_user in users)
        self.assertTrue(register_user(new_user))

        users = get_users()
        self.assertEqual(len(users), first_users_len + 1)
        self.assertTrue(new_user in users)
Beispiel #8
0
    root.resizable(0, 0)
    try:
        root.iconbitmap(default=join("media", "icon.ico"))
    except tk.TclError:
        logger.error("Icon could not be loaded\nYou probably use linux")
    rootSize = ((mapSize[0] * 16 + 6 + 6 + 5 + 3) * factor,
                (mapSize[1] * 16 + 6 + 49 + 5 + 4 + 19) * factor)
    x = y = 0
    geometry = "%dx%d+%d+%d" % (*rootSize, x, y)
    root.geometry(geometry)
    root.columnconfigure(0, weight=1)
    root.rowconfigure(1, weight=1)
    # Menu
    menu = tk.Frame(root, bg="#ece9d8", height=19 * factor)
    folderPath = join("cache", str(factor), "")
    menuImage = tk.PhotoImage(file=folderPath + "menu.gif")
    menuLabel = tk.Label(menu, image=menuImage, bg="#ece9d8", bd=0)
    # App
    app = App(root, factor, mapSize, nMines)
    # Grid
    menu.grid(column=0, row=0, sticky="NSEW")
    menuLabel.grid(column=0, row=0, sticky="NSW")
    app.grid(column=0, row=1, padx=(3, 0), pady=(4, 0), sticky="SE")

    root.mainloop()


if __name__ == "__main__":
    from main import prepare
    run_game(*prepare())
Beispiel #9
0
from util import *
from main import prepare, valid, submit
from bagging import build_models

prepare(CountVectorizer, 'bag_of_words')
build_models('bag_of_words', 1, [0, 1, 2, 3])
for name in names:
    valid('bag_of_words', name, 1, 32)
    submit('bag_of_words', name, 1, 32)