Beispiel #1
0
def main():
    ray.init()
    server = pype.Server.remote()
    server.add.remote('data_0', use_locking=True)
    server.add.remote('data_1', use_locking=True)
    server.add.remote('data_2', use_locking=True)
    server.add.remote('data_3', use_locking=True)
    server.add.remote('data_4', use_locking=True)
    server.add.remote('data_5', use_locking=True)
    server.add.remote('data_6', use_locking=True)

    start.remote(server, 'data_0')

    f.remote(server, 'data_1', 'data_2')
    f.remote(server, 'data_2', 'data_3')
    f.remote(server, 'data_3', 'data_4')
    f.remote(server, 'data_4', 'data_5')
    f.remote(server, 'data_5', 'data_6')

    for i in range(100):
        pype.pull_wait(server, 'data_6')
        data = ray.get(server.pull.remote('data_6'))
        print("Received ", data)
        server.print_queue.remote('data_6')

    time.sleep(3)
    ray.shutdown()
Beispiel #2
0
def main():
    init_ray()
    server = pype.Server.remote()
    server.add.remote('data', use_locking=False)
    f.remote(server)

    for i in range(4):
        pype.pull_wait(server, 'data', batch_size=5)
        data = ray.get(
            server.pull.remote('data', batch_size=5, wait_batch=True))
        print(data)
Beispiel #3
0
 def main(self):
     while True:
         pype.pull_wait(self.server,
                        self.input_queue,
                        batch_size=self.batch_size)
         data = ray.get(
             self.server.pull.remote(self.input_queue,
                                     batch_size=self.batch_size,
                                     wrap=True))
         # self.model.infer(data)
         for q in self.output_queues:
             self.server.push.remote(data, self.output_queues, expand=True)
Beispiel #4
0
def main():
    pype.init_ray()
    server = pype.Server.remote()
    server.add.remote('frames', use_locking=False, batch_lock=10)
    video_server = pype.VideoServer.remote(server, camera=0, scale=0.5,
                                           output_queues=('frames'))
    while True:
        pype.pull_wait(server, 'frames', batch_size=10)
        data = ray.get(server.pull.remote('frames', batch_size=10,
                                          wrap=False, flip=True))
        if len(data) > 0:
            print("Len batch: ", len(data))
            for d in data:
                frame = d['frame']
                cv2.imshow('frames', frame)
                cv2.waitKey(1)
            print("Queue len: ", ray.get(
                server.queue_len.remote('frames')))
        else:
            time.sleep(1e-3)
Beispiel #5
0
def main():
    # ray.init()
    pype.init_ray()
    server = pype.Server.remote()
    server.add.remote('data_0', use_locking=False)
    server.add.remote('data_1', use_locking=False)
    server.add.remote('data_2', use_locking=False)
    ray.get(server.all_initalized.remote())

    start.remote(server, 'data_0')

    start_time = time.time()
    f.remote(server, 'data_0', 'data_1')
    f.remote(server, 'data_1', 'data_2')

    for i in range(100):
        pype.pull_wait(server, 'data_2')
        data = ray.get(server.pull.remote('data_2'))
        # print(data)
    elapsed = time.time()-start_time
    print("Elapsed: {}".format(elapsed))

    time.sleep(3)
    ray.shutdown()
Beispiel #6
0
def main():
    """Test Pype Video Streaming FPS"""
    ray.init()
    server = pype.Server.remote()
    server.add.remote('frames', use_locking=True)
    pype.VideoServer.remote(server, camera=0, scale=1, output_queues=('frames'))

    counter = 0
    start_time = time.time()

    while True:
        pype.pull_wait(server, 'frames')
        data = ray.get(
            server.pull.remote('frames', batch_size=-1, flip=True, wrap=True))
        counter += len(data)
        # for d in data:
        #     frame = d['frame']
        #     cv2.imshow('frames', frame)
        #     cv2.waitKey(1)
        if counter >= 1000:
            break

    elapsed = time.time() - start_time
    print('FPS: ', counter / elapsed)
Beispiel #7
0
def f(server, input_name, output_name):
    while True:
        pype.pull_wait(server, input_name)
        data = ray.get(server.pull.remote(input_name))[0]
        pype.push_wait(server, output_name)
        server.push.remote(data, output_name)
Beispiel #8
0
def main():
    #pype.init_ray()
    ray.init()

    ray.timeline(filename="timeline.json")

    server = pype.Server.remote()
    server.add.remote('frame', use_locking=False)
    #server.add.remote('person', use_locking=False)
    # # server.add.remote('face', use_locking=False)
    server.add.remote('pose', use_locking=False)
    server.add.remote('object', use_locking=False)
    server.add.remote('action', use_locking=False)
    # server.add.remote('action', use_locking=False)
    # server.add.remote('action1', use_locking=False)
    # server.add.remote('counter', use_locking=False)
    # server.add.remote('results')

    person_models = [
        NullDetector.remote(server,
                            input_queue='frame',
                            output_queues=['pose'],
                            batch_size=-1) for _ in range(1)
    ]
    person_models = [
        NullDetector.remote(server,
                            input_queue='pose',
                            output_queues=['object'],
                            batch_size=-1) for _ in range(1)
    ]
    person_models = [
        NullDetector.remote(server,
                            input_queue='object',
                            output_queues=['action'],
                            batch_size=-1) for _ in range(1)
    ]
    # person_models = [NullDetector.remote(server, input_queue='action',
    #                                      output_queues=['action1'],
    #                                      batch_size=-1) for _ in range(1)]
    # person_models = [NullDetector.remote(server, input_queue='action1',
    #                                      output_queues=['action2'],
    #                                      batch_size=-1) for _ in range(1)]
    # person_models = [NullDetector.remote(server, input_queue='action2',
    #                                      output_queues=['action3'],
    #                                      batch_size=-1) for _ in range(1)]
    # person_models = [NullDetector.remote(server, input_queue='action3',
    #                                      output_queues=['action4'],
    #                                      batch_size=-1) for _ in range(1)]
    # person_models = [NullDetector.remote(server, input_queue='action4',
    #                                      output_queues=['action5'],
    #                                      batch_size=-1) for _ in range(1)]
    # person_models = [NullDetector.remote(server, input_queue='action5',
    #                                      output_queues=['action6'],
    #                                      batch_size=-1) for _ in range(1)]
    # person_models = [NullDetector.remote(server, input_queue='action6',
    #                                      output_queues=['action7'],
    #                                      batch_size=-1) for _ in range(1)]
    time.sleep(3)
    ray.timeline(filename="timeline.json")
    for _ in range(1):
        NullVideoServer.remote(server, output_queues='frame')
    # person_models = [NullDetector.remote(server, input_queue='action1',
    #                                      output_queues=['action2'],
    #                                      batch_size=-1) for _ in range(1)]
    # person_models = [NullDetector.remote(server, input_queue='action2',
    #                                      output_queues=['action3'],
    #                                      batch_size=-1) for _ in range(1)]
    # person_models = [NullDetector.remote(server, input_queue='action3',
    #                                      output_queues=['action4'],
    #                                      batch_size=-1) for _ in range(1)]
    # person_models = [NullDetector.remote(server, input_queue='action4',
    #                                      output_queues=['action5'],
    #                                      batch_size=-1) for _ in range(1)]
    # person_models = [NullDetector.remote(server, input_queue='action5',
    #                                      output_queues=['action6'],
    #                                      batch_size=-1) for _ in range(1)]
    # person_models = [NullDetector.remote(server, input_queue='action6',
    #                                      output_queues=['action7'],
    #                                      batch_size=-1) for _ in range(1)]
    # pose_models = [NullDetector.remote(server, input_queue='pose',
    #                                    output_queues=['object']) for _ in range(1)]
    # face_models = [NullDetector.remote(server, input_queue='face',
    #                                    output_queues=['results']) for _ in range(1)]
    # counter_models = [NullDetector.remote(server, input_queue='person',
    #                                       output_queues=['results']) for _ in range(1)]
    # object_models = [NullDetector.remote(server, input_queue='object',
    #                                      output_queues=['action']) for _ in range(1)]
    # action_models = [NullDetector.remote(server, input_queue='action',
    #                                      output_queues=['results']) for _ in range(1)]
    ray.get(server.all_initalized.remote())
    time_elapsed = 0
    count = 0
    start_time = time.time()
    ray.timeline(filename="timeline.json")
    while True:
        pype.pull_wait(server, 'action')
        data = ray.get(server.pull.remote('action'))
        #time_elapsed += time.time()-data[0]
        count += len(data)
        # print(count)
        if time.time() - start_time > 10:
            ray.timeline(filename="timeline.json")
            break

    print("Throughput: {}".format(count / (time.time() - start_time)))
    ray.shutdown()