Exemplo n.º 1
0
    def setUp(self):
        self.mc = create_client()
        self.bucket_name = get_random_bucket_name()
        self.input_prefix = 'test/'
        self.output_prefix = 'output_test/'
        self.image_name = 'test.jpg'
        self.object_name = os.path.join(self.input_prefix, self.image_name)
        self.output_object_name = os.path.join(self.output_prefix,
                                               self.image_name)
        self.metadata = {'X-Amz-Meta-Mqtt_topic': 'sensor/camera1'}

        make_bucket_if_not_exists(self.mc, self.bucket_name)

        self.tf_sess = create_detection_session(DETECTION_MODEL_PATH)
Exemplo n.º 2
0
    def run(self):
        print('Running MinioEventThread')
        mc = create_client()

        while True:
            print('Connecting to minio event stream')
            response = get_minio_notification_response(mc, self.__bucket_name,
                                                       self.__prefix)
            self.__event_stream_it = MinioEventStreamIterator(response)

            try:
                for event in self.__event_stream_it:
                    self.__q.put(event)
            except json.JSONDecodeError:
                response.close()
            except AttributeError:
                break
Exemplo n.º 3
0
def detection_loop(q: Queue, bucket_name: str, input_prefix: str,
                   output_prefix: str):
    tf_sess = create_detection_session(DETECTION_MODEL_PATH)
    mc = create_client()

    objects = mc.list_objects_v2(bucket_name,
                                 prefix=input_prefix,
                                 recursive=True)
    for obj in objects:
        if obj.is_dir:
            continue
        safe_process_file_object(mc, tf_sess, obj.bucket_name, obj.object_name,
                                 input_prefix, output_prefix)

    while True:
        event = q.get()
        if event is None:
            break

        for obj_bucket_name, obj_key in iterate_objects(event):
            safe_process_file_object(mc, tf_sess, obj_bucket_name, obj_key,
                                     input_prefix, output_prefix)
Exemplo n.º 4
0
 def setUp(self):
     self.mc = create_client()
     self.bucket_name = get_random_bucket_name()
     make_bucket_if_not_exists(self.mc, self.bucket_name)
Exemplo n.º 5
0
 def setUp(self):
     self.mc = create_client()
     self.bucket_name = get_random_bucket_name()