jcarnero commited on
Commit
96037a8
1 Parent(s): f4f8da1

rrc test shows it is not equal to croppad

Browse files
tests/test_transforms.py CHANGED
@@ -22,7 +22,7 @@ def get_birds_images(path: Path) -> List[str]:
22
 
23
 
24
  class TestTransforms:
25
- im_idx = 0
26
 
27
  @pytest.fixture
28
  def img_paths(self) -> List[str]:
@@ -30,19 +30,28 @@ class TestTransforms:
30
  return get_birds_images(path.resolve())
31
 
32
  @pytest.fixture
33
- def im_fastai(self, img_paths) -> PILImage:
34
  fname = img_paths[self.im_idx]
35
  return PILImage.create(fname)
36
 
37
  @pytest.fixture
38
- def im_pil(self, img_paths) -> Image:
39
  fname = img_paths[self.im_idx]
40
  return Image.open(fname)
41
 
42
- def testImageFastaiEqualsPillow(self, im_fastai, im_pil):
43
  assert (np.array(im_fastai) == np.array(im_pil)).all()
44
 
45
- def testCropPadFastaiEqualsTorch(self, im_fastai, im_pil):
 
 
 
 
 
 
 
 
 
46
  crop_fastai = fastai_aug.CropPad((460, 460))
47
  crop_torch = CenterCropPad((460, 460))
48
 
 
22
 
23
 
24
  class TestTransforms:
25
+ im_idx = 50
26
 
27
  @pytest.fixture
28
  def img_paths(self) -> List[str]:
 
30
  return get_birds_images(path.resolve())
31
 
32
  @pytest.fixture
33
+ def im_fastai(self, img_paths: List[str]) -> PILImage:
34
  fname = img_paths[self.im_idx]
35
  return PILImage.create(fname)
36
 
37
  @pytest.fixture
38
+ def im_pil(self, img_paths: List[str]) -> Image:
39
  fname = img_paths[self.im_idx]
40
  return Image.open(fname)
41
 
42
+ def testImageFastaiEqualsPillow(self, im_fastai: PILImage, im_pil: Image):
43
  assert (np.array(im_fastai) == np.array(im_pil)).all()
44
 
45
+ def testRandomResizedCropEqualsCropPadInValidation(self, im_fastai: PILImage):
46
+ crop_fastai = fastai_aug.CropPad((460, 460))
47
+ crop_rrc = fastai_aug.RandomResizedCrop((460, 460))
48
+
49
+ cropped_fastai = crop_rrc(im_fastai, split_idx=1)
50
+ cropped_rrc = crop_fastai(im_fastai, split_idx=1)
51
+
52
+ assert (np.array(cropped_rrc) == np.array(cropped_fastai)).all()
53
+
54
+ def testCropPadFastaiEqualsTorch(self, im_fastai: PILImage, im_pil: Image):
55
  crop_fastai = fastai_aug.CropPad((460, 460))
56
  crop_torch = CenterCropPad((460, 460))
57
 
training/notebooks/transforms-lab.ipynb CHANGED
The diff for this file is too large to render. See raw diff