Skip to content

Instantly share code, notes, and snippets.

@cluePrints
Created February 10, 2019 02:23
Show Gist options
  • Save cluePrints/cb8cde19c6094b889c8ff407f3f1ad69 to your computer and use it in GitHub Desktop.
Save cluePrints/cb8cde19c6094b889c8ff407f3f1ad69 to your computer and use it in GitHub Desktop.
test_1602
def test_resize_with_no_tfms(path_var_size):
for p in [path_var_size]:
fnames = get_files(p/'train', recurse=True)
pat = r'/([^/]+)\/\d+.png$'
for size in [14, (14,14), (14,20)]:
with CaptureStderr() as cs:
data = (ImageItemList(fnames, path=p)
.no_split()
.label_const()
.transform(size=size) # No tfms here
.databunch(bs=2))
assert len(cs.err)==0, f"got collate_fn warning {cs.err}"
x,_ = data.train_ds[0]
size_want = (size, size) if isinstance(size, int) else size
size_real = x.size
assert size_want == size_real, f"size mismatch after resize {size} expected {size_want}, got {size_real}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment