def get_model_and_optimizer(model_class, model_path, cfg): device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu") ngpu = 1 if torch.cuda.is_available() else 0 network = model_class(ngpu, cfg).to(device) if cfg["RMSprop"]: optimizer = optim.RMSprop(network.parameters(), lr=cfg["lr"]) else: optimizer = optim.Adam(network.parameters(), lr=cfg["lr"], betas=(cfg["beta1"], 0.999)) initialise(network, model_path) print(network) return network, optimizer
def index(): """index view showing the user their board(s)""" models.User.update(UserType=99).where( models.User.UserName == 'admin').execute() if current_user.get_usertype() == 99: boards = models.Board.select() return render_template('index.html', boards=boards, admin=True, models=models) boards = models.User.get_boards(g.user.id) return render_template('index.html', boards=boards) if __name__ == 'app': models.initialise() try: # creates a user for testing models.User.create_user(username="******", email="*****@*****.**", password=os.environ.get('ADMIN_PASS'), usertype=99) print('created admin user') except ValueError: pass # different host for web server if os.uname().nodename == 'Georges-MacBook-Pro-2.local': app.run(debug=DEBUG, port=int(os.environ.get('PORT', 5000)), use_reloader=True,
mqtt_client.disconnect() logger.info('Dereticulating splines... Done!') sys.exit(0) if __name__ == '__main__': arguments = docopt(__doc__, version='Listener v1.0') logger = log.init_log('listener') signal.signal(signal.SIGTERM, shutdown) cfg = get_config(None) initialise(cfg.get('KEYSPACE', 'drastic'), hosts=cfg.get('CASSANDRA_HOSTS', ('127.0.0.1', ))) if arguments['--verbose']: logger.setLevel(logging.DEBUG) elif arguments['--quiet']: logger.setLevel(logging.WARNING) else: logger.setLevel(logging.INFO) script_directory_topic = '+/resource/{0}/#'.format( arguments['<script_collection>']) script_directory_topic = '/'.join( filter(None, script_directory_topic.split('/'))) script_directory = arguments['<script_directory>'] scan_script_collection(arguments['<script_collection>'])
logger.info('Dereticulating splines... Done!') sys.exit(0) if __name__ == '__main__': arguments = docopt(__doc__, version='Listener v1.0') logger = log.init_log('listener') signal.signal(signal.SIGTERM, shutdown) cfg = get_config(None) initialise(keyspace=cfg.get('KEYSPACE', 'indigo'), hosts=cfg.get('CASSANDRA_HOSTS', ('127.0.0.1', )), repl_factor=cfg.get('REPLICATION_FACTOR', 1)) if arguments['--verbose']: logger.setLevel(logging.DEBUG) elif arguments['--quiet']: logger.setLevel(logging.WARNING) else: logger.setLevel(logging.INFO) script_directory_topic = '+/resource/{0}/#'.format( arguments['<script_collection>']) script_directory_topic = '/'.join( filter(None, script_directory_topic.split('/'))) script_directory = arguments['<script_directory>'] scan_script_collection(arguments['<script_collection>'])
_test_dir = CONFIG['testing directory'] _pre_img_size = CONFIG['pre image size'] _post_img_size = CONFIG['post image size'] _lr = CONFIG['learning rate'] _output = CONFIG['output'] _network_name = CONFIG['network name'] cam = camera.Feed() draw = camera.Draw() model = models.initialise(model_name=MODEL_NAME, network_name=_network_name, image_size=_post_img_size, learning_rate=_lr, output=_output) def predict_and_parse(image_a, image_b): image_a = cam.resize(image_a, (200, 200)) image_b = cam.resize(image_b, (200, 200)) images = np.concatenate((image_a, image_b), axis=1) cam.out_one('ims1', images) test_img = cam.resize(images, _post_img_size) cam.out_one('ims2', test_img)