Skip to content
This repository has been archived by the owner on Oct 9, 2023. It is now read-only.

TypeError with Plant Pathology #836

Closed
carmocca opened this issue Oct 5, 2021 · 1 comment · Fixed by #1076
Closed

TypeError with Plant Pathology #836

carmocca opened this issue Oct 5, 2021 · 1 comment · Fixed by #1076
Labels
bug / fix Something isn't working help wanted Extra attention is needed won't fix This will not be worked on

Comments

@carmocca
Copy link
Contributor

carmocca commented Oct 5, 2021

🐛 Bug

To Reproduce

https://www.kaggle.com/c/plant-pathology-2021-fgvc8

See below:

Code sample

import flash
from flash.image import ImageClassificationData
import pandas as pd
data = pd.read_csv("train.csv")
data["filepath"] = "train_images/" + data["image"]
dm = ImageClassificationData.from_files(train_files=data["filepath"], train_targets=data.labels)
batch = next(iter(dm.train_dataloader()))
---------------------------------------------------------------------------

TypeError                                 Traceback (most recent call last)

/tmp/ipykernel_326/1146354640.py in <module>
----> 1 batch = next(iter(dm.train_dataloader()))


~/conda/lib/python3.8/site-packages/torch/utils/data/dataloader.py in __next__(self)
    519             if self._sampler_iter is None:
    520                 self._reset()
--> 521             data = self._next_data()
    522             self._num_yielded += 1
    523             if self._dataset_kind == _DatasetKind.Iterable and \


~/conda/lib/python3.8/site-packages/torch/utils/data/dataloader.py in _next_data(self)
   1201             else:
   1202                 del self._task_info[idx]
-> 1203                 return self._process_data(data)
   1204 
   1205     def _try_put_index(self):


~/conda/lib/python3.8/site-packages/torch/utils/data/dataloader.py in _process_data(self, data)
   1227         self._try_put_index()
   1228         if isinstance(data, ExceptionWrapper):
-> 1229             data.reraise()
   1230         return data
   1231 


~/conda/lib/python3.8/site-packages/torch/_utils.py in reraise(self)
    423             # have message field
    424             raise self.exc_type(message=msg)
--> 425         raise self.exc_type(msg)
    426 
    427 


TypeError: Caught TypeError in DataLoader worker process 0.
Original Traceback (most recent call last):
  File "/home/jovyan/conda/lib/python3.8/site-packages/torch/utils/data/_utils/worker.py", line 287, in _worker_loop
    data = fetcher.fetch(index)
  File "/home/jovyan/conda/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py", line 47, in fetch
    return self.collate_fn(data)
  File "/home/jovyan/conda/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1051, in _call_impl
    return forward_call(*input, **kwargs)
  File "/home/jovyan/conda/lib/python3.8/site-packages/flash/core/data/batch.py", line 221, in forward
    sample = self.per_sample_transform(sample)
  File "/home/jovyan/conda/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1051, in _call_impl
    return forward_call(*input, **kwargs)
  File "/home/jovyan/conda/lib/python3.8/site-packages/flash/core/data/batch.py", line 76, in forward
    sample = self.to_tensor_transform(sample)
  File "/home/jovyan/conda/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1051, in _call_impl
    return forward_call(*input, **kwargs)
  File "/home/jovyan/conda/lib/python3.8/site-packages/flash/core/data/utils.py", line 178, in forward
    return self.func(*args, **kwargs)
  File "/home/jovyan/conda/lib/python3.8/site-packages/flash/core/data/process.py", line 351, in to_tensor_transform
    return self.current_transform(sample)
  File "/home/jovyan/conda/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1051, in _call_impl
    return forward_call(*input, **kwargs)
  File "/home/jovyan/conda/lib/python3.8/site-packages/torch/nn/modules/container.py", line 139, in forward
    input = module(input)
  File "/home/jovyan/conda/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1051, in _call_impl
    return forward_call(*input, **kwargs)
  File "/home/jovyan/conda/lib/python3.8/site-packages/flash/core/data/transforms.py", line 47, in forward
    result[keys[0]] = super().forward(inputs[0])
  File "/home/jovyan/conda/lib/python3.8/site-packages/torch/nn/modules/container.py", line 139, in forward
    input = module(input)
  File "/home/jovyan/conda/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1051, in _call_impl
    return forward_call(*input, **kwargs)
  File "/home/jovyan/conda/lib/python3.8/site-packages/flash/core/data/utils.py", line 178, in forward
    return self.func(*args, **kwargs)
TypeError: new(): invalid data type 'str'

Expected behavior

TypeError

Environment

  • PyTorch Version (e.g., 1.0):
  • OS (e.g., Linux):
  • How you installed PyTorch (conda, pip, source):
  • Build command you used (if compiling from source):
  • Python version:
  • CUDA/cuDNN version:
  • GPU models and configuration:
  • Any other relevant information:

Additional context

@stale
Copy link

stale bot commented Dec 5, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the won't fix This will not be worked on label Dec 5, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug / fix Something isn't working help wanted Extra attention is needed won't fix This will not be worked on
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant