REPOSITORY TAG IMAGE ID
fastdotai/fastai-course latest 020ece1e8fca
Setting-up type transforms pipelines
Collecting items from /root/.fastai/data/oxford-iiit-pet/images
Found 7390 items
2 datasets of sizes 5912,1478
Setting up Pipeline: PILBase.create
Setting up Pipeline: partial -> Categorize -- {'vocab': None, 'sort': True, 'add_na': False}
Building one sample
Pipeline: PILBase.create
starting from
/root/.fastai/data/oxford-iiit-pet/images/english_cocker_spaniel_145.jpg
applying PILBase.create gives
PILImage mode=RGB size=391x500
Pipeline: partial -> Categorize -- {'vocab': None, 'sort': True, 'add_na': False}
starting from
/root/.fastai/data/oxford-iiit-pet/images/english_cocker_spaniel_145.jpg
applying partial gives
english_cocker_spaniel
applying Categorize -- {'vocab': None, 'sort': True, 'add_na': False} gives
TensorCategory(18)
Final sample: (PILImage mode=RGB size=391x500, TensorCategory(18))
Collecting items from /root/.fastai/data/oxford-iiit-pet/images
Found 7390 items
2 datasets of sizes 5912,1478
Setting up Pipeline: PILBase.create
Setting up Pipeline: partial -> Categorize -- {'vocab': None, 'sort': True, 'add_na': False}
Setting up after_item: Pipeline: ToTensor
Setting up before_batch: Pipeline:
Setting up after_batch: Pipeline: IntToFloatTensor -- {'div': 255.0, 'div_mask': 1}
Building one batch
Applying item_tfms to the first sample:
Pipeline: ToTensor
starting from
(PILImage mode=RGB size=391x500, TensorCategory(18))
applying ToTensor gives
(TensorImage of size 3x500x391, TensorCategory(18))
Adding the next 3 samples
No before_batch transform to apply
Collating items in a batch
Error! It's not possible to collate your items in a batch
Could not collate the 0-th members of your tuples because got the following shapes
torch.Size([3, 500, 391]),torch.Size([3, 374, 500]),torch.Size([3, 375, 500]),torch.Size([3, 279, 300])
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
/tmp/ipykernel_45/2530811607.py in <module>
4 splitter=RandomSplitter(seed=42),
5 get_y=using_attr(RegexLabeller(r'(.+)_\d+.jpg$'), 'name'))
----> 6 pets1.summary(path/"images")
/opt/conda/lib/python3.8/site-packages/fastai/data/block.py in summary(self, source, bs, show_batch, **kwargs)
188 why = _find_fail_collate(s)
189 print("Make sure all parts of your samples are tensors of the same size" if why is None else why)
--> 190 raise e
191
192 if len([f for f in dls.train.after_batch.fs if f.name != 'noop'])!=0:
/opt/conda/lib/python3.8/site-packages/fastai/data/block.py in summary(self, source, bs, show_batch, **kwargs)
182 print("\nCollating items in a batch")
183 try:
--> 184 b = dls.train.create_batch(s)
185 b = retain_types(b, s[0] if is_listy(s) else s)
186 except Exception as e:
/opt/conda/lib/python3.8/site-packages/fastai/data/load.py in create_batch(self, b)
141 elif s is None: return next(self.it)
142 else: raise IndexError("Cannot index an iterable dataset numerically - must use `None`.")
--> 143 def create_batch(self, b): return (fa_collate,fa_convert)[self.prebatched](b)
144 def do_batch(self, b): return self.retain(self.create_batch(self.before_batch(b)), b)
145 def to(self, device): self.device = device
/opt/conda/lib/python3.8/site-packages/fastai/data/load.py in fa_collate(t)
48 b = t[0]
49 return (default_collate(t) if isinstance(b, _collate_types)
---> 50 else type(t[0])([fa_collate(s) for s in zip(*t)]) if isinstance(b, Sequence)
51 else default_collate(t))
52
/opt/conda/lib/python3.8/site-packages/fastai/data/load.py in <listcomp>(.0)
48 b = t[0]
49 return (default_collate(t) if isinstance(b, _collate_types)
---> 50 else type(t[0])([fa_collate(s) for s in zip(*t)]) if isinstance(b, Sequence)
51 else default_collate(t))
52
/opt/conda/lib/python3.8/site-packages/fastai/data/load.py in fa_collate(t)
47 "A replacement for PyTorch `default_collate` which maintains types and handles `Sequence`s"
48 b = t[0]
---> 49 return (default_collate(t) if isinstance(b, _collate_types)
50 else type(t[0])([fa_collate(s) for s in zip(*t)]) if isinstance(b, Sequence)
51 else default_collate(t))
/opt/conda/lib/python3.8/site-packages/torch/utils/data/_utils/collate.py in default_collate(batch)
53 storage = elem.storage()._new_shared(numel)
54 out = elem.new(storage)
---> 55 return torch.stack(batch, 0, out=out)
56 elif elem_type.__module__ == 'numpy' and elem_type.__name__ != 'str_' \
57 and elem_type.__name__ != 'string_':
/opt/conda/lib/python3.8/site-packages/fastai/torch_core.py in __torch_function__(self, func, types, args, kwargs)
338 convert=False
339 if _torch_handled(args, self._opt, func): convert,types = type(self),(torch.Tensor,)
--> 340 res = super().__torch_function__(func, types, args=args, kwargs=kwargs)
341 if convert: res = convert(res)
342 if isinstance(res, TensorBase): res.set_meta(self, as_copy=True)
/opt/conda/lib/python3.8/site-packages/torch/tensor.py in __torch_function__(cls, func, types, args, kwargs)
960
961 with _C.DisableTorchFunction():
--> 962 ret = func(*args, **kwargs)
963 return _convert(ret, cls)
964
RuntimeError: stack expects each tensor to be equal size, but got [3, 500, 391] at entry 0 and [3, 374, 500] at entry 1