Hello, I have been running the Lesson2_download notebook on Paperspace and followed all the directions for setting up my environment.
When I get to the ‘Cleaning Up’ section in the lesson the cell fails to run and gives me a AttributeError: ‘Tensor’ object has no attribute ‘ndim’.
Here is the whole error message:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-27-1a5a092880e1> in <module>
----> 1 ImageCleaner(ds, idxs, path)
2 # from tqdm.autonotebook import tqdm
/opt/conda/envs/fastai/lib/python3.6/site-packages/fastai/widgets/image_cleaner.py in __init__(self, dataset, fns_idxs, path, batch_size, duplicates)
210 self._csv_dict = {dataset.x.items[i]: dataset.y[i] for i in range(len(dataset))}
211 self._deleted_fns:List[Path] = []
--> 212 self.next_batch()
213
214 def make_payload(self, idx:int): return {'file_path': self._dataset.x.items[idx]}
/opt/conda/envs/fastai/lib/python3.6/site-packages/fastai/widgets/image_cleaner.py in next_batch(self, _)
193 "Fetches a next batch of images for rendering."
194 if self.before_next_batch and hasattr(self, '_batch_payloads'): self.before_next_batch(self._batch_payloads)
--> 195 batch = tuple(islice(self._all_images, self.batch_size))
196 self._batch_payloads = tuple(b.payload for b in batch)
197 self.render(batch)
/opt/conda/envs/fastai/lib/python3.6/site-packages/fastai/widgets/image_cleaner.py in create_image_list(self, fns_idxs, drop_batch_on_nonfile)
172 else chain.from_iterable(c for c in chunks(fns_idxs, self.batch_size)
173 if all(Path(items[i]).is_file() for i in c)))
--> 174 for i in idxs: yield ImgData(self._dataset.x[i]._repr_jpeg_(), self._get_label(i), self.make_payload(i))
175
176 def _get_label(self, idx):
/opt/conda/envs/fastai/lib/python3.6/site-packages/fastai/data_block.py in __getitem__(self, idxs)
117 def __getitem__(self,idxs:int)->Any:
118 "returns a single item based if `idxs` is an integer or a new `ItemList` object if `idxs` is a range."
--> 119 idxs = try_int(idxs)
120 if isinstance(idxs, Integral): return self.get(idxs)
121 else: return self.new(self.items[idxs], inner_df=index_row(self.inner_df, idxs))
/opt/conda/envs/fastai/lib/python3.6/site-packages/fastai/torch_core.py in try_int(o)
365 "Try to convert `o` to int, default to `o` if not possible."
366 # NB: single-item rank-1 array/tensor can be converted to int, but we don't want to do this
--> 367 if isinstance(o, (np.ndarray,Tensor)): return o if o.ndim else int(o)
368 if isinstance(o, collections.Sized) or getattr(o,'__array_interface__',False): return o
369 try: return int(o)
AttributeError: 'Tensor' object has no attribute 'ndim'
Does anyone know how to resolve the issue? I tried searching the forums and online but couldn’t seem to find anything related to the problem. I’ve tried making sure that I am in a notebook and not a lab.