def main(): # pragma: no cover parser = argparse.ArgumentParser( prog='BeesBook pipeline batch processor', description='Batch process video using the beesbook pipeline') parser.add_argument('video_root_path', help='root path of input videos', type=str) for arg, kwargs in chain(get_shared_positional_arguments(), get_shared_optional_arguments()): parser.add_argument(arg, **kwargs) args = parser.parse_args() pipeline_cmd = None if os.path.exists(os.path.join(os.getcwd(), 'bb_pipeline')): pipeline_cmd = os.path.join(os.getcwd(), 'bb_pipeline') else: pipeline_cmd = shutil.which('bb_pipeline') assert(pipeline_cmd is not None) video_files = [] for root, dirs, files in os.walk(args.video_root_path): for file in files: video_files.append(os.path.join(root, file)) logger.info('Processing files: \n\t{}'.format('\n\t'.join(video_files))) for fname in video_files: cmd_args = [fname] + \ list([args.__dict__[param] for param, _ in get_shared_positional_arguments()]) for param, _ in get_shared_optional_arguments(): if param[2:] in args.__dict__: cmd_args.append(param) cmd_args.append(str(args.__dict__[param[2:]])) call([pipeline_cmd] + cmd_args)
def main(): # pragma: no cover comm = MPI.COMM_WORLD rank = comm.Get_rank() if 'PIPELINE_TMP_DIR' in os.environ: compile_dir = '{}/theano_compile_process_{}'.format(os.environ['PIPELINE_TMP_DIR'], rank) os.environ["THEANO_FLAGS"] = ("base_compiledir='{}'".format(compile_dir)) atexit.register(delete_folder, compile_dir) from pipeline.cmdline import logger info = lambda msg: logger.info('Process {}: {}'.format(rank, msg)) video_list_path, repo_output_path, ts_format, text_root_path = parse_args(comm) video_paths = [s.strip() for s in open(video_list_path, 'r').readlines()] if rank is 0: logger.info('There are {} processes'.format(comm.Get_size())) if rank < len(video_paths): process_video(video_paths[rank], repo_output_path, ts_format, text_root_path, rank) else: logger.warning('Process {}: No file to process'.format(rank)) info('Reached Barrier.') comm.Barrier() info('Exiting.')
def main(): # pragma: no cover comm = MPI.COMM_WORLD rank = comm.Get_rank() if 'PIPELINE_TMP_DIR' in os.environ: compile_dir = '{}/theano_compile_process_{}'.format( os.environ['PIPELINE_TMP_DIR'], rank) os.environ["THEANO_FLAGS"] = ( "base_compiledir='{}'".format(compile_dir)) atexit.register(delete_folder, compile_dir) from pipeline.cmdline import logger info = lambda msg: logger.info('Process {}: {}'.format(rank, msg)) video_list_path, repo_output_path, ts_format, text_root_path = parse_args( comm) video_paths = [s.strip() for s in open(video_list_path, 'r').readlines()] if rank is 0: logger.info('There are {} processes'.format(comm.Get_size())) if rank < len(video_paths): process_video(video_paths[rank], repo_output_path, ts_format, text_root_path, rank) else: logger.warning('Process {}: No file to process'.format(rank)) info('Reached Barrier.') comm.Barrier() info('Exiting.')
def main(): # pragma: no cover comm = MPI.COMM_WORLD rank = comm.Get_rank() if "PIPELINE_TMP_DIR" in os.environ: compile_dir = "{}/theano_compile_process_{}".format( os.environ["PIPELINE_TMP_DIR"], rank) os.environ["THEANO_FLAGS"] = f"base_compiledir='{compile_dir}'" atexit.register(delete_folder, compile_dir) from pipeline.cmdline import logger info = lambda msg: logger.info(f"Process {rank}: {msg}") video_list_path, repo_output_path, ts_format, text_root_path = parse_args( comm) video_paths = [s.strip() for s in open(video_list_path).readlines()] if rank == 0: logger.info(f"There are {comm.Get_size()} processes") if rank < len(video_paths): process_video(video_paths[rank], repo_output_path, ts_format, text_root_path, rank) else: logger.warning(f"Process {rank}: No file to process") info("Reached Barrier.") comm.Barrier() info("Exiting.")
def main(): # pragma: no cover parser = argparse.ArgumentParser( prog='BeesBook pipeline', description='Process a video using the beesbook pipeline') parser.add_argument('video_path', help='path of input video', type=str) for arg, kwargs in chain(get_shared_positional_arguments(), get_shared_optional_arguments()): parser.add_argument(arg, **kwargs) args = parser.parse_args() logger.info('Processing video: {}'.format(args.video_path)) logger.info('Config: {}'.format(args)) process_video(args)
def main(): # pragma: no cover parser = argparse.ArgumentParser( prog="BeesBook pipeline", description="Process a video using the beesbook pipeline", ) parser.add_argument("video_path", help="path of input video", type=str) for arg, kwargs in chain(get_shared_positional_arguments(), get_shared_optional_arguments()): parser.add_argument(arg, **kwargs) args = parser.parse_args() logger.info(f"Processing video: {args.video_path}") logger.info(f"Config: {args}") process_video(args)
def process_video(args): config = get_auto_config() logger.info('Initializing {} pipeline(s)'.format(args.num_threads)) plines = [Pipeline([Image, Timestamp], [PipelineResult], **config) for _ in range(args.num_threads)] logger.info('Loading bb_binary repository {}'.format(args.repo_output_path)) repo = Repository(args.repo_output_path) camId, _, _ = parse_video_fname(args.video_path) logger.info('Parsed camId = {}'.format(camId)) gen_processor = GeneratorProcessor(plines, lambda: BBBinaryRepoSink(repo, camId=camId)) logger.info('Processing video frames from {}'.format(args.video_path)) gen_processor(video_generator(args.video_path, args.timestamp_format, args.text_root_path))
def main(): # pragma: no cover parser = argparse.ArgumentParser( prog='BeesBook pipeline batch processor', description='Batch process video using the beesbook pipeline') parser.add_argument('video_root_path', help='root path of input videos', type=str) for arg, kwargs in chain(get_shared_positional_arguments(), get_shared_optional_arguments()): parser.add_argument(arg, **kwargs) args = parser.parse_args() pipeline_cmd = None if os.path.exists(os.path.join(os.getcwd(), 'bb_pipeline')): pipeline_cmd = os.path.join(os.getcwd(), 'bb_pipeline') else: pipeline_cmd = shutil.which('bb_pipeline') assert (pipeline_cmd is not None) video_files = [] for root, dirs, files in os.walk(args.video_root_path): for file in files: video_files.append(os.path.join(root, file)) logger.info('Processing files: \n\t{}'.format('\n\t'.join(video_files))) for fname in video_files: cmd_args = [fname] + \ list([args.__dict__[param] for param, _ in get_shared_positional_arguments()]) for param, _ in get_shared_optional_arguments(): if param[2:] in args.__dict__: cmd_args.append(param) cmd_args.append(str(args.__dict__[param[2:]])) call([pipeline_cmd] + cmd_args)
def process_video(args): config = get_auto_config() logger.info('Initializing {} pipeline(s)'.format(args.num_threads)) plines = [ Pipeline([Image, Timestamp], [PipelineResult], **config) for _ in range(args.num_threads) ] logger.info('Loading bb_binary repository {}'.format( args.repo_output_path)) repo = Repository(args.repo_output_path) camId, _, _ = parse_video_fname(args.video_path) logger.info('Parsed camId = {}'.format(camId)) gen_processor = GeneratorProcessor( plines, lambda: BBBinaryRepoSink(repo, camId=camId)) logger.info('Processing video frames from {}'.format(args.video_path)) gen_processor( video_generator(args.video_path, args.timestamp_format, args.text_root_path))