def check_opts(opts): opts.resized_dir = os.path.abspath(opts.resized_dir) opts.seg_dir = os.path.abspath(opts.seg_dir) opts.deeplab_path = os.path.abspath(opts.deeplab_path) opts.inputFileName = opts.in_path.split('/')[-1] opts.styleFileName = opts.style_path.split('/')[-1] opts.checkpointName = opts.checkpoint_dir.split('/')[-1].split('.')[0] opts.resized_path = os.path.join(opts.resized_dir, opts.inputFileName) opts.resized_style_path = os.path.join(opts.resized_dir, opts.styleFileName) opts.seg_path = os.path.join(opts.seg_dir, opts.inputFileName) opts.seg_style_path = os.path.join(opts.seg_dir, opts.styleFileName) ensure_folders(input_dir) ensure_folders(resized_dir) ensure_folders(style_dir) ensure_folders(seg_dir) ensure_folders(output_dir) # !!! IF NAMES MATCH, THROW EXCEPTION TO PREVENT OVERWRITING !!! if opts.inputFileName == opts.styleFileName: raise ValueError('Input and style file names cannot be the same') exists(opts.checkpoint_dir, 'Checkpoint not found!') exists(opts.in_path, 'In path not found!') return opts
def check_opts(opts): exists(opts.checkpoint_dir, "checkpoint dir not found!") exists(opts.style, "style path not found!") exists(opts.train_path, "train path not found!") exists(opts.vgg_path, "vgg network data not found!") assert opts.epochs > 0 and opts.batch_size > 0 and opts.checkpoint_iterations > 0 \ and os.path.exists(opts.vgg_path) and opts.content_weight >= 0 and opts.style_weight >= 0 \ and opts.tv_weight >= 0 and opts.learning_rate >= 0
def check_opts(opts): exists(opts.checkpoint_dir, "checkpoint dir not found!") exists(opts.train_path, "train path not found!") if opts.test or opts.test_dir: exists(opts.test, "test img not found!") exists(opts.test_dir, "test directory not found!") exists(opts.vgg_path, "vgg network data not found!") assert opts.epochs > 0 assert opts.batch_size > 0 assert opts.checkpoint_iterations > 0 assert os.path.exists(opts.vgg_path) assert opts.content_weight >= 0 assert opts.style_weight >= 0 assert opts.tv_weight >= 0 assert opts.learning_rate >= 0
def _login(): logger.info('/login called') sp = _spotify_oauth() cookie_token = _get_token(request) if exists(cookie_token): logger.info('Token found') current_token = sp.cookie_to_dict(cookie_token) if sp.is_token_expired(current_token): logger.info('Token is expired - requesting new token') refresh_token = sp.refresh_token(current_token) refresh_token['refresh_token'] = current_token['refresh_token'] current_token = refresh_token logger.info('Redirecting to /mix') response = make_response(redirect('/mix')) cookie = sp.json_to_cookie(current_token) logger.info('Setting token as cookie: %s' % cookie) response.set_cookie('spotify_token', cookie) return response else: logger.info('No token found - getting one') return redirect(sp.get_auth_url(), code=302)
def check_opts(opts): exists(opts.checkpoint_dir, 'Checkpoint not found!') exists(opts.in_path, 'In path not found!') if not os.path.exists(opts.out_path): os.mkdir(opts.out_path) if os.path.isdir(opts.out_path): exists(opts.out_path, 'out dir not found!') assert opts.batch_size > 0
def check_opts(opts): exists(opts.checkpoint) exists(opts.out)
def test_exists__fail(self, value): assert exists(value) is False
def test_exists__pass(self, value): assert exists(value)
def check_opts(opts): exists(opts.style, "style model not found!") exists(opts.content, "content image not found!")