Ejemplo n.º 1
0
def fault_cl():
    # Create new config
    (cfg_path, cfg) = make_config(master_port='5010',
                                  worker_port='5011',
                                  path='/tmp/config_test')

    # Setup and ingest video
    with Client(master='localhost:5010',
                workers=[],
                config_path=cfg_path,
                no_workers_timeout=120,
                enable_watchdog=False,
                debug=True) as cl:
        (vid1_path, vid2_path) = download_videos()

        cl.load_op(
            os.path.abspath(
                os.path.join(cwd, '..', 'build/tests/libscanner_tests.so')),
            os.path.abspath(
                os.path.join(cwd, '..', 'build/tests/test_ops_pb2.py')))

        cl.ingest_videos([('test1', vid1_path), ('test2', vid2_path)])

        yield cl

        # Tear down
        run([
            'rm', '-rf', cfg['storage']['db_path'], cfg_path, vid1_path,
            vid2_path
        ])
Ejemplo n.º 2
0
def timeout_cl():
    # Create new config
    (cfg_path, cfg) = make_config(master_port='5155', worker_port='5160')

    # Setup and ingest video
    master = 'localhost:5155'
    workers = ['localhost:{:04d}'.format(5160 + d) for d in range(4)]
    with Client(config_path=cfg_path,
                no_workers_timeout=120,
                master=master,
                workers=workers,
                enable_watchdog=False) as cl:
        (vid1_path, vid2_path) = download_videos()

        cl.ingest_videos([('test1', vid1_path), ('test2', vid2_path)])

        yield cl

        for worker in workers:
            channel = grpc.insecure_channel(worker)
            worker_stub = protobufs.WorkerStub(channel)
            try:
                worker_stub.Shutdown(protobufs.Empty(),
                                     timeout=cl._grpc_timeout)
            except grpc.RpcError as e:
                pass

        # Tear down
        run([
            'rm', '-rf', cfg['storage']['db_path'], cfg_path, vid1_path,
            vid2_path
        ])
Ejemplo n.º 3
0
def cl():
    # Create new config
    (cfg_path, cfg) = make_config()

    # Setup and ingest video
    with Client(config_path=cfg_path, debug=True) as cl:
        (vid1_path, vid2_path) = download_videos()

        cl.load_op(
            os.path.abspath(
                os.path.join(cwd, '..', 'build/tests/libscanner_tests.so')),
            os.path.abspath(
                os.path.join(cwd, '..', 'build/tests/test_ops_pb2.py')))

        cl.ingest_videos([('test1', vid1_path), ('test2', vid2_path)])

        cl.ingest_videos([('test1_inplace', vid1_path),
                          ('test2_inplace', vid2_path)],
                         inplace=True)

        yield cl

        # Tear down
        run([
            'rm', '-rf', cfg['storage']['db_path'], cfg_path, vid1_path,
            vid2_path
        ])
Ejemplo n.º 4
0
def no_workers_cl():
    # Create new config
    (cfg_path, cfg) = make_config(master_port='5020', worker_port='5021')

    # Setup and ingest video
    with Client(workers=[],
                config_path=cfg_path,
                enable_watchdog=False,
                debug=True) as cl:
        (vid1_path, vid2_path) = download_videos()

        cl.ingest_videos([('test1', vid1_path), ('test2', vid2_path)])

        yield cl

        # Tear down
        run([
            'rm', '-rf', cfg['storage']['db_path'], cfg_path, vid1_path,
            vid2_path
        ])
Ejemplo n.º 5
0
def sc():
    # Create new config
    (cfg_path, cfg) = make_config()

    # Setup and ingest video
    with Client(config_path=cfg_path, debug=True) as sc:
        (vid1_path, vid2_path) = download_videos()

        sc.ingest_videos([('test1', vid1_path), ('test2', vid2_path)])

        sc.ingest_videos([('test1_inplace', vid1_path),
                          ('test2_inplace', vid2_path)],
                         inplace=True)

        yield sc

        # Tear down
        run([
            'rm', '-rf', cfg['storage']['db_path'], cfg_path, vid1_path,
            vid2_path
        ])
Ejemplo n.º 6
0
def blacklist_cl():
    # Create new config
    (cfg_path, cfg) = make_config(master_port='5055', worker_port='5060')

    # Setup and ingest video
    master = 'localhost:5055'
    workers = ['localhost:{:04d}'.format(5060 + d) for d in range(4)]
    with Client(config_path=cfg_path,
                no_workers_timeout=120,
                master=master,
                workers=workers,
                enable_watchdog=False) as cl:
        (vid1_path, vid2_path) = download_videos()

        cl.ingest_videos([('test1', vid1_path), ('test2', vid2_path)])

        yield cl

        # Tear down
        run([
            'rm', '-rf', cfg['storage']['db_path'], cfg_path, vid1_path,
            vid2_path
        ])
Ejemplo n.º 7
0
def main():

    print("Prepare videos and frames")
    # video = Video.objects.filter(path__contains='men_single_final_gold')[0]
    # movie_path = video.path
    # movie_name = video.item_name()

    sc = Client()
    stride = 1
    input_stream = NamedVideoStream(sc, movie_name, path=movie_path)
    frame = sc.io.Input([input_stream])
    strided_frame = sc.streams.Stride(frame, [stride])

    print('Running Scanner MaskRCNN op')
    maskrcnn_frame = sc.ops.MaskRCNNDetectObjects(
        frame=strided_frame,
        device=DeviceType.GPU,  #if sc.has_gpu() else DeviceType.CPU,
        batch=8,
        confidence_threshold=0.5,
        min_image_size=800)
    maskrcnn_stream = NamedStream(sc, movie_name + '_maskrcnn')
    output_op = sc.io.Output(maskrcnn_frame, [maskrcnn_stream])
    sc.run(output_op,
           scannerpy.common.PerfParams.estimate(),
           cache_mode=scannerpy.CacheMode.Ignore)

    print('Writing MaskRCNN metadata into frames')
    drawn_frame = sc.ops.DrawMaskRCNN(frame=strided_frame,
                                      bundled_data=sc.io.Input(
                                          [maskrcnn_stream]),
                                      min_score_thresh=0.5)
    drawn_stream = NamedVideoStream(sc, movie_name + '_maskrcnn_draw')
    output_op = sc.io.Output(drawn_frame, [drawn_stream])
    sc.run(output_op,
           scannerpy.common.PerfParams.estimate(),
           cache_mode=scannerpy.CacheMode.Overwrite)
    drawn_stream.save_mp4('/app/result/' + movie_name + '_maskrcnn')
Ejemplo n.º 8
0
def main():

    print("Prepare videos and frames")
    video = Video.objects.filter(path__contains='wim')[0]
    video_path = video.path
    video_name = video.item_name()

    sc = Client()
    stride = 1
    input_stream = NamedVideoStream(sc, video_name, path=video_path)
    frame = sc.io.Input([input_stream])

    # run on all frames
    # running_frame = sc.streams.Stride(frame, [stride])

    hit_annotation = pickle.load(
        open('/app/data/pkl/hit_annotation_tennis.pkl',
             'rb'))[video_name + '.mp4']
    # run on selected frames

    # 	hit_dict = []
    # 	for h in hit_annotation.values():
    # 		hit_dict += h
    hit_dict = hit_annotation

    # 	frame_ids = [i for point in hit_dict for i in range(point[0]['fid']-25, point[-1]['fid']+25) ]
    frame_ids = [
        i for point in hit_dict for i in range(point[0] - 25, point[-1] + 25)
    ]

    frame_ids.sort()
    running_frame = sc.streams.Gather(frame, [frame_ids])

    print('Running Scanner DensePose op on %d frames' % (len(frame_ids)))
    densepose_frame = sc.ops.DensePoseDetectPerson(frame=running_frame,
                                                   device=DeviceType.GPU,
                                                   batch=1,
                                                   confidence_threshold=0.5,
                                                   nms_threshold=0.2)
    densepose_stream = NamedStream(sc, video_name + '_densepose')
    output_op = sc.io.Output(densepose_frame, [densepose_stream])
    sc.run(output_op,
           scannerpy.common.PerfParams.estimate(),
           cache_mode=scannerpy.CacheMode.Overwrite)

    exit()

    print('Writing DensePose metadata into frames')
    drawn_frame = sc.ops.DrawDensePose(frame=running_frame,
                                       bundled_data=sc.io.Input(
                                           [densepose_stream]),
                                       min_score_thresh=0.5,
                                       show_body=True)
    drawn_stream = NamedVideoStream(sc, video_name + '_densepose_draw_uvbody')
    output_op = sc.io.Output(drawn_frame, [drawn_stream])
    sc.run(output_op,
           scannerpy.common.PerfParams.estimate(),
           cache_mode=scannerpy.CacheMode.Overwrite)
    drawn_stream.save_mp4('/app/result/' + video_name + '_densepose_uvbody')

    drawn_frame = sc.ops.DrawDensePose(frame=running_frame,
                                       bundled_data=sc.io.Input(
                                           [densepose_stream]),
                                       min_score_thresh=0.5,
                                       show_body=False)
    drawn_stream = NamedVideoStream(sc, video_name + '_densepose_draw_full')
    output_op = sc.io.Output(drawn_frame, [drawn_stream])
    sc.run(output_op,
           scannerpy.common.PerfParams.estimate(),
           cache_mode=scannerpy.CacheMode.Overwrite)
    drawn_stream.save_mp4('/app/result/' + video_name + '_densepose_full')
Ejemplo n.º 9
0
from scannerpy import Client
sc = Client(workers=[
    'ocean.pdl.local.cmu.edu:15559', 'crissy.pdl.local.cmu.edu:15559'
])