pyronear / pyro-vision

Computer vision library for wildfire detection 🌲 Deep learning models in PyTorch & ONNX for inference on edge devices (e.g. Raspberry Pi)

Home Page:https://pyronear.org/pyro-vision/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[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 -->

https://github.com/frgfm/PyroNear/blob/61d5d527187a6f6b0696da0bc199c1a80a2ee2c0/pyronear/datasets/wildfire/wildfire.py#L31-L32

str is not supported by PyTorch when iterating trough DataLoader

To Reproduce

Steps to reproduce the behavior:

  1. str path

path_to_frames = "/Users/sebastienelmaleh/Google Drive/Deep Learning/Pyronear/frames_raw_wildfire/"

  1. 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?

@frgfm, Yes I will open a PR asap :)

commented

@Akilditu : Do you need any help with this?

@x0s Thanks for asking but opening the PR today