Multi-Label classification, TypeError: argument 1 must be an iterator

I keep getting ‘TypeError: argument 1 must be an iterator’ for the following:

src = (ImageList.from_csv(path, 'labels.csv', folder='train', suffix='.jpg')
       .label_from_df(label_delim=' ')

It seems to be being triggered on .label_from_df(label_delim=’ ') - any ideas?

Running on GCP, pytorch 1.2, fastai was on 058, have updated to 059 - still get the same.

Since it is a csv file, the delimeter should be a comma. Open the file and check any row.

Thanks, I’ve tried that - still the same error

I’ve also tried with:

src = (ImageList.from_df(df, path, folder='train', suffix='.jpg', cols='image_name')
       .label_from_df(label_delim=' ', cols='tags'))

but get the same iterator error

Try possibly changing the - in your labels to _. I don’t believe that would make a difference but it may.

@muellerzr nope still get the iterator error - thanks though, I’ve tried changing the separator too e.g ; or : nothing though seems to work

src = (ImageList.from_csv(path, 'labels.csv', folder='train', suffix='.jpg')

runs without errors, but how then do I add in the labels after this for databunch?

1 Like

For csv use from_csv
For dataframe use from_df

As in .labels_from_df? If so, that’s where the issue of this thread starts.

Or are you referring to using from_csv or from_df elsewhere?

Can you post the whole stack-trace of your error? It’ll be easier to investigate that way as we’ll be able to see exactly where in the data block API this issue is cropping up.

The whole error is in the screenshot at the very top, if you click on it, it all shows

Did nothing, but came back and it now works…