Пример #1
0
 def __init__(self, batch_size, num_threads, device_id):
     super(ElementExtractPipeline, self).__init__(batch_size, num_threads, device_id)
     self.inputs = ops.ExternalSource()
     # Extract first element in each sample
     self.element_extract_first = ops.ElementExtract(element_map=[0])
     # Extract last element in each sample
     self.element_extract_last = ops.ElementExtract(element_map=[F-1])
     # Extract both first and last element in each sample to two separate outputs
     self.element_extract_first_last = ops.ElementExtract(element_map=[0, F-1])
Пример #2
0
    def __init__(self, batch_size: int, num_threads: int, device_id: int,
                 sequence_length: int, initial_prefetch_size: int, data: List,
                 shuffle: bool):
        """
        :param batch_size: size of dataset batch
        :param num_threads: number of parallel threads
        :param device_id: "gpu" or "cpu"
        :param sequence_length: number of frames
        :param initial_prefetch_size: count of videos readed preliminarily
        :param data: input video paths
        :param shuffle: suffle samples
        """
        super().__init__(batch_size, num_threads, device_id, seed=16)
        self.input = ops.VideoReader(device="gpu",
                                     filenames=data,
                                     sequence_length=sequence_length,
                                     shard_id=0,
                                     num_shards=1,
                                     random_shuffle=shuffle,
                                     initial_fill=initial_prefetch_size)

        self.extract = ops.ElementExtract(device="gpu",
                                          element_map=list(
                                              range(0, FRAMES_PER_VIDEO)))

        self.resize = ops.Resize(device="gpu",
                                 resize_x=config.IMG_SIZE,
                                 resize_y=config.IMG_SIZE)