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

#1

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

src = (ImageList.from_csv(path, 'labels.csv', folder='train', suffix='.jpg')
       .split_by_rand_pct(0.2)
       .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.

0 Likes

(Dinesh Arora) #2

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

0 Likes

#3

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

0 Likes

#4

I’ve also tried with:

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

but get the same iterator error

0 Likes

(Zachary Mueller) #5

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

0 Likes

#6

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

0 Likes

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

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

1 Like

#8

For csv use from_csv
For dataframe use from_df

0 Likes

#9

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?

0 Likes

(Akash Palrecha) #10

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.

0 Likes

#11

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

0 Likes

#12

Did nothing, but came back and it now works…

0 Likes