def test_basic(self): pipe_count = utp.Counter() output = [] for i in xrange(3): output.append(next(pipe_count.out)) expected = [0, 1, 2] self.assertTrue(output == expected, msg=utg.errmsg(output, expected))
def jpg2npy(folder_name, prefix, ids=None): path = os.path.abspath(folder_name) pipe_reader = utp.FolderReader(path, prefix=prefix, ids=ids, suffix='jpg') pipe_counter = utp.Counter() pipe_writer = utp.FolderWriter(path, prefix, pipe_reader, pipe_counter) pipe_runner = utp.Runner(pipe_writer) pipe_runner.run()
def proj2sino(folder, prefix_old, prefix_new, id0, id1, folder_out=None): # TODO: Reimplementation if folder_out is None: folder_out = folder pipe_input = utp.FolderReader(folder, prefix_old, ids=xrange(id0, id1)) pipe_sino = utp.Proj2Sino(pipe_input) pipe_count = utp.Counter() pipe_output = utp.FolderWriter( folder_out, prefix_new, pipe_sino, pipe_count)
def pad_sino(source, target, prefix, pwx, pwy): if isinstance(source, (list, tuple)): for folder in source: pad_sino(folder, target, prefix, pwx, pwy) return None pipe_filename = utp.FileNameLooper(source, prefix) pipe_sino2d = utp.NPYReaderSingle(pipe_filename) pipe_padded = utp.PeriodicalPadding(pipe_sino2d, pwx, pwx, pwy, pwy) pipe_counter = utp.Counter() pipe_sino2dwirter = utp.FolderWriter( target, prefix, pipe_padded, pipe_counter) pipe_runner = utp.Runner(pipe_sino2dwirter) pipe_runner.run()
def sino3d2sino2d(source, target, prefix): if isinstance(source, (list, tuple)): for folder in source: sino3d2sino2d(folder, target, prefix) return None pipe_filename = utp.FileNameLooper(source, prefix) pipe_sino3d = utp.NPYReaderSingle(pipe_filename) pipe_conv3d2d = utp.Sino3D2Sino2D(pipe_sino3d) pipe_buffer = utp.Buffer(pipe_conv3d2d) pipe_counter = utp.Counter() pipe_sino2dwirter = utp.FolderWriter( target, prefix, pipe_buffer, pipe_counter) pipe_runner = utp.Runner(pipe_sino2dwirter) pipe_runner.run()
def _prepare(self): """Prepare work before dataset is ready to use. """ self._epoch = utp.Counter(max_state=self._epoch_max) # No more epoch flag is set to False only once here. When it is True, # Calling batch_start() will raise StopIteration exception. self._is_next_epoch = True self._is_next_epoch_to_be_true = False self._is_no_more_epoch = False # Work with self._is_lock, when self._is_next_file is False, Calling # _end_of_sinle_file() will results _padding(), otherwise it will load # next file and return sample() self._is_next_file = True self._is_next_file_to_be_true = False self._is_no_more_sample = False
def test_max(self): pipe_count = utp.Counter() pipe_count.max_state = 5 output = [cnt for cnt in pipe_count.out] expected = [0, 1, 2, 3, 4] self.assertTrue(output == expected, msg=utg.errmsg(output, expected))