Esempio n. 1
0
def test_one_epoch(args, model, test_loader):
	model.eval()
	test_loss = 0.0
	pred  = 0.0
	count = 0
	AP_List = []
	GT_Size_List = []
	precision_list = []
	registration_model = Registration(args.reg_algorithm)

	for i, data in enumerate(tqdm(test_loader)):
		template, source, igt, gt_mask = data

		template = template.to(args.device)
		source = source.to(args.device)
		igt = igt.to(args.device)						# [source] = [igt]*[template]
		gt_mask = gt_mask.to(args.device)

		masked_template, predicted_mask = model(template, source)
		result = registration_model.register(masked_template, source)
		est_T = result['est_T']
		
		# Evaluate mask based on classification metrics.
		accuracy, precision, recall, fscore = evaluate_mask(gt_mask, predicted_mask, predicted_mask_idx = model.mask_idx)
		precision_list.append(precision)
		
		# Different ways to visualize results.
		display_results(template.detach().cpu().numpy()[0], source.detach().cpu().numpy()[0], est_T.detach().cpu().numpy()[0], masked_template.detach().cpu().numpy()[0])

	print("Mean Precision: ", np.mean(precision_list))
Esempio n. 2
0
def main():
    """The main function sets up and kicks off all of the listeners"""
    # This restores the Ctrl+C signal handler, normally the loop ignores it
    signal.signal(signal.SIGINT, signal.SIG_DFL)

    # Initialize devices
    loop = asyncio.get_event_loop()
    lid = setup_lid_controller(loop)

    # Initialize queue
    bin_q = asyncio.Queue()

    # Argument setup and parsing
    args = get_args()
    offline = args.offline

    # Registration
    if not offline:
        registration = Registration(config_file_name='test_config.json')
        print('Checking registration...')
        if not registration.is_registered():
            print('No registration found. Creating registration')
            registration.register()
        else:
            print('Registration found')
        config = registration.config

    # Setup pedal events with GPIO
    setup_gpio(loop, bin_q)

    # Schedule the tasks
    tasks = [move_consumer(bin_q, lid)]
    if not offline:
        tasks.append(handler_persistance_warpper(bin_q, config))
    for task in tasks:
        asyncio.ensure_future(task)

    # Setup loop in debug mode to catch anything weird
    loop.set_debug(True)

    # Run event loop forever
    print('Beginning event loop')
    loop.run_forever()
    loop.close()

    # Be nice and cleanup
    GPIO.cleanup()
Esempio n. 3
0
class RegisterCommand(Command):
    def __init__(self):
        Command.__init__(self)
        self.registration = Registration()
        self.only_public_chats = True

    def run(self):
        user = self.last_update.message.from_user
        chat = self.last_update.message.chat
        name = self.get_display_name(user)

        if self.registration.is_user_registered(chat, user):
            self.reply_with_text(f"{name} уже зарегистрирован")
        else:
            self.registration.register(chat, user)
            self.reply_with_text(
                f'Теперь ты зарегистрирован в пидоре дня, {name}')
Esempio n. 4
0
 def activity(self):
     speak.Speak("Please Log in")
     login = Login()
     name = login.login_check()
     while name == 0:
         name = login.login_check()
     if name == -1:
         quit(-1)
     elif name[0] == "Friend":
         reg = Registration()
         result = reg.register(name[1])
         if result == -8:
             speak.Speak(
                 "Your details have been updated. Please login again.")
             quit()
     else:
         speak.Speak("Let's get started")
         menu = Menu()
         menu.menu_options(name)
Esempio n. 5
0
from registration import Registration

reg = Registration()

email = input('Input email: ')
password = input('Input password: ')

reg.register(email, password)