Пример #1
0
def run_benchmarks(benchmark_params, test_root, force=False):
    """Run the benchmarks
    
    For every row in benchmark params, run a trace on the input video
    using the params specified.
    
    benchmark_params: DataFrame with columns corresponding to keywords
        to pass to pipeline_trace. Should have columns 'name',
        'input_video', 'chunk_sz_frames', 'epoch_sz_frames',
        'frame_start', 'frame_stop', 'n_trace_processes', etc
    
    Returns:
        test_results, durations
        test_results : Dict from test['name'] to results read from hdf5 file
        durations : list of durations taken
    """
    WhiskiWrap.utils.probe_needed_commands()

    test_results = {}
    durations = []
    for idx, test in benchmark_params.iterrows():
        print(test['name'])
        test_dir = os.path.expanduser(os.path.join(test_root, test['name']))
        fn = setup_session_directory(test_dir,
                                     test['input_video'],
                                     force=force)

        # Run
        start_time = time.time()
        WhiskiWrap.pipeline_trace(fn.video('mp4'),
                                  fn.hdf5,
                                  chunk_sz_frames=test['chunk_sz_frames'],
                                  epoch_sz_frames=test['epoch_sz_frames'],
                                  frame_start=test['frame_start'],
                                  frame_stop=test['frame_stop'],
                                  n_trace_processes=test['n_trace_processes'])
        stop_time = time.time()
        durations.append(stop_time - start_time)

        # Get the summary
        with tables.open_file(fn.hdf5) as fi:
            test_results[test['name']] = pandas.DataFrame.from_records(
                fi.root.summary.read())

    return test_results, durations
Пример #2
0
def run_benchmarks(benchmark_params, test_root, force=False):
    """Run the benchmarks
    
    For every row in benchmark params, run a trace on the input video
    using the params specified.
    
    benchmark_params: DataFrame with columns corresponding to keywords
        to pass to pipeline_trace. Should have columns 'name',
        'input_video', 'chunk_sz_frames', 'epoch_sz_frames',
        'frame_start', 'frame_stop', 'n_trace_processes', etc
    
    Returns:
        test_results, durations
        test_results : Dict from test['name'] to results read from hdf5 file
        durations : list of durations taken
    """
    WhiskiWrap.utils.probe_needed_commands()
    
    test_results = {}
    durations = []    
    for idx, test in benchmark_params.iterrows():
        print test['name']
        test_dir = os.path.expanduser(os.path.join(test_root, test['name']))
        fn = setup_session_directory(test_dir, test['input_video'], force=force)

        # Run
        start_time = time.time()
        WhiskiWrap.pipeline_trace(
            fn.video('mp4'),
            fn.hdf5,
            chunk_sz_frames=test['chunk_sz_frames'],
            epoch_sz_frames=test['epoch_sz_frames'],
            frame_start=test['frame_start'],
            frame_stop=test['frame_stop'],
            n_trace_processes=test['n_trace_processes'])
        stop_time = time.time()
        durations.append(stop_time - start_time)

        # Get the summary
        with tables.open_file(fn.hdf5) as fi:
            test_results[test['name']] = pandas.DataFrame.from_records(
                fi.root.summary.read()) 
    
    return test_results, durations
Пример #3
0
        assert args.video_path is not None, 'Video path must be specified when video path is given.'
        video_path = args.video_path

    # working directory is always the script directory
    wdir = os.getcwd()
    # get video name
    video_fname = os.path.basename(video_path)
    video_name = ''.join(video_fname.split('.')[:-1])
    # output_path has the same name of the video name plus whiki_
    output_path = os.path.join(wdir, 'whiski_' + video_name)
    # creates output path if it doesn't exists
    if not os.path.exists(output_path):
        warn('out path didn\'t exist creating output path ' + output_path)
        os.mkdir(output_path)
    # copies video if it is not there (in the output path)
    input_video = os.path.join(output_path, video_fname)
    if not os.path.exists(input_video):
        warn('input video didn\'t exist coping from source ' + output_path)
        shutil.copy(video_path, input_video)
    output_file = os.path.join(output_path, video_name + '.hdf5')
    freeze_support()
    input_video = os.path.expanduser(input_video)
    output_file = os.path.expanduser(output_file)
    print('input_video ', input_video)
    print('output_file', output_file)

    WhiskiWrap.pipeline_trace(input_video,
                              output_file,
                              n_trace_processes=4,
                              chunk_sz_frames=100)