Flash fails to load image labels from CSV on Kaggle RANZCR CLiP - Catheter and Line Position Challenge
See original GitHub issue🐛 Bug
The master code does not properly load labels from CSV for image classification. Trying to get a baseline working for the Catheter and Line Position Challenge and am currently blocked.
To Reproduce
Steps to reproduce the behavior:
- !pip install git+https://github.com/PyTorchLightning/lightning-flash.git@master
- Run ‘…’
import os
import flash
from flash.core.data import download_data
from flash.core.finetuning import FreezeUnfreeze
from flash.vision import ImageClassificationData, ImageClassifier
data = ImageClassificationData(
train_filepaths='/kaggle/input/ranzcr-clip-catheter-line-classification/train',
train_labels='/kaggle/input/ranzcr-clip-catheter-line-classification/train.csv',
valid_filepaths='/kaggle/input/ranzcr-clip-catheter-line-classification/test',
valid_labels='/kaggle/input/ranzcr-clip-catheter-line-classification/test.csv'
)
Stack Trace
Successfully installed datasets-1.2.1 lightning-flash-0.2.1.dev0 pandas-1.1.2 pycocotools-2.0.2 pytorch-lightning-1.2.0rc0 pytorch-lightning-bolts-0.3.0 pytorch-tabnet-3.1.1 rouge-score-0.0.4 scikit-learn-0.24.0 torch-1.7.1 torchvision-0.8.2 tqdm-4.49.0 xxhash-2.0.0 TypeError
TypeError Traceback (most recent call last) <ipython-input-5-1ea2eb98cece> in <module> 3 train_labels=‘/kaggle/input/ranzcr-clip-catheter-line-classification/train.csv’, 4 valid_filepaths=‘/kaggle/input/ranzcr-clip-catheter-line-classification/test’, ----> 5 valid_labels=‘/kaggle/input/ranzcr-clip-catheter-line-classification/test.csv’ 6 )
/opt/conda/lib/python3.7/site-packages/pytorch_lightning/core/datamodule.py in call(cls, *args, **kwargs) 48 49 # Get instance of LightningDataModule by mocking its init via call —> 50 obj = type.call(cls, *args, **kwargs) 51 52 return obj
TypeError: init() got an unexpected keyword argument ‘train_filepaths’ init() got an unexpected keyword argument ‘train_filepaths’ Enter console command here
Expected behavior
Data Module loads labels without issue
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (5 by maintainers)

Top Related StackOverflow Question
You need to use
ImageClassificationData.from_filepaths(), and then supply the filenames and labels as lists. The image paths will need to be extracted from the csv, something like:NOTE: looking at the Kaggle competition this data appears to be multi-label, which the ImageClassificationData does not support (yet?)
https://github.com/PyTorchLightning/lightning-flash/blob/master/flash/data/data_utils.py#L6