Getting errors when trying to add a dataset for testing as validation set in my multi-label classification model


I have successfully trained a model to do multi-label classification of Power Quality Disturbances with 9 classes, using Efficientnet-b0.
I used 5folds stratified cross validation (scikit learn) for the training:

from sklearn.model_selection import StratifiedKFold
skf=StratifiedKFold(n_splits=5, random_state=1, shuffle=True)
for train_index, val_index in skf.split(df.index, df[‘Tags’]):
src = (ImageList.from_df(df, base_dir)
.label_from_df(label_delim=’ '))
data_fold = (src.transform(None, size=64).databunch().normalize(imagenet_stats))
learn = Learner(data_fold, arch, metrics=acc_02, callback_fns=ShowGraph)
learn.fit_one_cycle(30, slice(lr))
loss,acc = learn.validate()

But, it has been days that I am trying to test the model on a dataset individually (each class seperatly), for no avail.

My goal is to assess the performance of the model in detecting each class, using recall, precision, and accuracy.

I have arranged the testing dataset in folders, each defining one class (I have 20 combinations along with the 9 main classes, thus I have 29 folders).

Yet, when I try to create a DataBlock for the first class:

src_test=(ImageList.from_csv(base_dir_test,‘Test_Flicker.csv’).split_none().label_from_df(label_delim=’ '))
data_test= (src_test.transform(None, size=64).databunch().normalize(imagenet_stats))

I get the following error:

The loss function used is FlattenedLoss of BCEWithLogitsLoss()

When you do a show_batch() with data_test does it look fine?