Esempio n. 1
0
    def __init__ (self, samples_path, debug, batch_size, sort_by_yaw=False, sort_by_yaw_target_samples_path=None, with_close_to_self=False, sample_process_options=SampleProcessor.Options(), output_sample_types=[], add_sample_idx=False, generators_count=2, **kwargs):
        super().__init__(samples_path, debug, batch_size)
        self.sample_process_options = sample_process_options
        self.output_sample_types = output_sample_types
        self.add_sample_idx = add_sample_idx
               
        if sort_by_yaw_target_samples_path is not None:
            self.sample_type = SampleType.FACE_YAW_SORTED_AS_TARGET
        elif sort_by_yaw:
            self.sample_type = SampleType.FACE_YAW_SORTED
        elif with_close_to_self:
            self.sample_type = SampleType.FACE_WITH_CLOSE_TO_SELF
        else:
            self.sample_type = SampleType.FACE         
  
        self.samples = SampleLoader.load (self.sample_type, self.samples_path, sort_by_yaw_target_samples_path)        

        if self.debug:
            self.generators_count = 1
            self.generators = [iter_utils.ThisThreadGenerator ( self.batch_func, 0 )]
        else:
            self.generators_count = min ( generators_count, len(self.samples) )
            self.generators = [iter_utils.SubprocessGenerator ( self.batch_func, i ) for i in range(self.generators_count) ]

        self.generators_sq = [ multiprocessing.Queue() for _ in range(self.generators_count) ]
            
        self.generator_counter = -1
Esempio n. 2
0
    def __init__(self,
                 samples_path,
                 debug,
                 batch_size,
                 sort_by_yaw=False,
                 sort_by_yaw_target_samples_path=None,
                 sample_process_options=SampleProcessor.Options(),
                 output_sample_types=[],
                 **kwargs):
        super().__init__(samples_path, debug, batch_size)
        self.sample_process_options = sample_process_options
        self.output_sample_types = output_sample_types

        if sort_by_yaw_target_samples_path is not None:
            self.sample_type = SampleType.FACE_YAW_SORTED_AS_TARGET
        elif sort_by_yaw:
            self.sample_type = SampleType.FACE_YAW_SORTED
        else:
            self.sample_type = SampleType.FACE

        self.samples = SampleLoader.load(self.sample_type, self.samples_path,
                                         sort_by_yaw_target_samples_path)

        if self.debug:
            self.generator_samples = [self.samples]
            self.generators = [
                iter_utils.ThisThreadGenerator(self.batch_func, 0)
            ]
        else:
            if len(self.samples) > 1:
                self.generator_samples = [
                    self.samples[0::2], self.samples[1::2]
                ]
                self.generators = [
                    iter_utils.SubprocessGenerator(self.batch_func, 0),
                    iter_utils.SubprocessGenerator(self.batch_func, 1)
                ]
            else:
                self.generator_samples = [self.samples]
                self.generators = [
                    iter_utils.SubprocessGenerator(self.batch_func, 0)
                ]

        self.generator_counter = -1
    def __init__(self,
                 samples_path,
                 debug,
                 batch_size,
                 temporal_image_count,
                 sample_process_options=SampleProcessor.Options(),
                 output_sample_types=[],
                 **kwargs):
        super().__init__(samples_path, debug, batch_size)

        self.temporal_image_count = temporal_image_count
        self.sample_process_options = sample_process_options
        self.output_sample_types = output_sample_types

        self.samples = SampleLoader.load(SampleType.IMAGE, self.samples_path)

        self.generator_samples = [self.samples]
        self.generators = [iter_utils.ThisThreadGenerator ( self.batch_func, 0 )] if self.debug else \
                          [iter_utils.SubprocessGenerator ( self.batch_func, 0 )]

        self.generator_counter = -1