[datasets] Documentation error within WildfireDataset class where path_to_frame should be a path type
Akilditu opened this issue Β· comments
π Bug
path_to_frame
should be a path type and not an str as mentioned below -->
str is not supported by PyTorch when iterating trough DataLoader
To Reproduce
Steps to reproduce the behavior:
- str path
path_to_frames = "/Users/sebastienelmaleh/Google Drive/Deep Learning/Pyronear/frames_raw_wildfire/"
- Iterating through DataLoader
for epoch in range(num_epochs):
for i, (images, labels) in enumerate(wildfire_loader_train):
which produces :
TypeError Traceback (most recent call last)
in
4 iter = 0
5 for epoch in range(num_epochs):
----> 6 for i, (images, labels) in enumerate(wildfire_loader_train):
7
8 labels = labels.squeeze()
/usr/local/lib/python3.7/site-packages/torch/utils/data/dataloader.py in next(self)
344 def next(self):
345 index = self._next_index() # may raise StopIteration
--> 346 data = self._dataset_fetcher.fetch(index) # may raise StopIteration
347 if self._pin_memory:
348 data = _utils.pin_memory.pin_memory(data)
/usr/local/lib/python3.7/site-packages/torch/utils/data/_utils/fetch.py in fetch(self, possibly_batched_index)
42 def fetch(self, possibly_batched_index):
43 if self.auto_collation:
---> 44 data = [self.dataset[idx] for idx in possibly_batched_index]
45 else:
46 data = self.dataset[possibly_batched_index]
/usr/local/lib/python3.7/site-packages/torch/utils/data/_utils/fetch.py in (.0)
42 def fetch(self, possibly_batched_index):
43 if self.auto_collation:
---> 44 data = [self.dataset[idx] for idx in possibly_batched_index]
45 else:
46 data = self.dataset[possibly_batched_index]
~/seb_PyroNear/PyroNear/pyronear/datasets/wildfire/wildfire.py in getitem(self, index)
59 - x,y (float, float) and
60 - Exploitable(True/False)"""
---> 61 path_to_frame = self.path_to_frames / self.metadata['imgFile'].iloc[index]
62 observation = self.load_image(path_to_frame)
63
TypeError: unsupported operand type(s) for /: 'str' and 'str'
Expected behavior
Importing pathlib and converting str to path type corrected the error
Fully agree with you @Akilditu! Would you mind opening a PR for this?