def __init__(self, patients, transform=[None, None], feature=None, cores=None, p=1, task=None, process=False): if task is None: task = Task() task.start(name='IDC Dataset', desc='Loading Images...') if transform is None: transform = [None, None] if process: self.data, self.classes = task.pool( proc_wrapper, patients, process=True, shared_args=[transform[0], transform[1], p, feature], shared_init=pinit, name='Loader', recursive=True, reducer=proc_reducer, cores=cores) else: self.data, self.classes = task.pool(load_patient, patients, process=False, shared_kwargs={ 'transform': transform, 'feature': feature, 'p': p }, reducer=reducer, name='Loader', recursive=False, threads=cores) task.done(self.data, self.classes, desc="{n} images ({p}%) sampled from {k} patients".format( n=self.classes.shape[0], k=len(patients), p=p * 100))
def __new(self, task, cores): if task is None: task = Task() task.start(name='Random Binning Feature', desc=self.__str__()) gen = task.pool(get_p_set, [self.d for _ in range(self.D)], cores=cores, process=True, name='Random Binning Feature') self.delta = np.array([x[0] for x in gen], dtype=np.float32) self.mu = np.array([x[1] for x in gen], dtype=np.float32) task.done(self.delta, self.mu, desc="{desc} created".format(desc=self.__str__()))