コード例 #1
0
    def _get_loader(self, cache_input, cache_output):
        if cache_input == 'disk':
            input_loader = FileCachedLoader(self.cache_dir, self.input, progress_callback=self._progress_callback)
        elif cache_input == 'mem':
            input_loader = MemoryCachedLoader(self.cache_dir, self.input, progress_callback=self._progress_callback)
        else:
            input_loader = self.input

        if cache_output == 'disk':
            return FileCachedLoader(self.cache_dir, input_loader, self.ops, self.output, progress_callback=self._progress_callback)
        elif cache_output == 'mem':
            return MemoryCachedLoader(self.cache_dir, input_loader, self.ops, self.output, progress_callback=self._progress_callback)
        else:
            return LiveLoader(self.cache_dir, input_loader, self.ops, self.output)
コード例 #2
0
def test_mem_out_loader_with_ops_meta(tmpdir):
    cache_dir = _prepare_dir(tmpdir)
    st = SourceTest({'samples-dir': str(tmpdir)})
    loader = MemoryCachedLoader(cache_dir,
                                st,
                                ops=[AppendStringOperation()],
                                output=st)
    _test_loader_meta(loader)
コード例 #3
0
def test_mem_loader_with_rng_no_reset(tmpdir):
    cache_dir = _prepare_dir(tmpdir)
    st = SourceTest({
        'samples-dir': str(tmpdir),
        'test-split': 2,
        'val-split': 2
    })
    loader = MemoryCachedLoader(cache_dir, st)
    _test_loader_with_rng_no_reset(loader)
コード例 #4
0
def test_mem_loader_ops_num_samples(tmpdir):
    cache_dir = _prepare_dir(tmpdir)
    st = SourceTest({'samples-dir': str(tmpdir)})
    loader = MemoryCachedLoader(cache_dir, st)
    loader2 = LiveLoader(cache_dir,
                         loader,
                         ops=[AppendStringOperation()],
                         output=st)
    _test_loader_num_samples(loader2)
コード例 #5
0
def test_mem_out_loader_with_ops(tmpdir):
    cache_dir = _prepare_dir(tmpdir)
    st = SourceTest({
        'samples-dir': str(tmpdir),
        'test-split': 2,
        'val-split': 2
    })
    loader = MemoryCachedLoader(cache_dir,
                                st,
                                ops=[AppendStringOperation()],
                                output=st)
    _test_loader_read_samples_transformed(loader)
コード例 #6
0
def test_mem_out_loader_with_multiplier_ops_between(tmpdir):
    cache_dir = _prepare_dir(tmpdir)
    st = SourceTest({
        'samples-dir': str(tmpdir),
        'test-split': 2,
        'val-split': 2
    })
    loader = MemoryCachedLoader(
        cache_dir,
        st,
        ops=[AugmentOperation(variants=2),
             AppendStringOperation()],
        output=st)
    _test_loader_read_samples_x2_between(loader)
コード例 #7
0
def test_mem_loader_num_samples(tmpdir):
    cache_dir = _prepare_dir(tmpdir)
    st = SourceTest({'samples-dir': str(tmpdir)})
    loader = MemoryCachedLoader(cache_dir, st)
    _test_loader_num_samples(loader)