Test Data set in get_ds()

I try to read in test data by using the code below,

class  MatchedFilesDataset(FilesDataset):
    def __init__(self, fnames, y, transform, path):
        self.y=y
        assert(len(fnames)==len(y))
        super().__init__(fnames, transform, path)
    def get_y(self, i): return open_image(os.path.join(self.path, self.y[i]))
    def get_c(self): return 0

import pandas as pd
testname = pd.read_csv("testfile.csv")
testname = ''.join(testname['0'].values.tolist())

TESTPATH = Path("../data/tgs/test")
test = (TESTPATH/testname, TESTPATH/testname) #testname is a list of the files in test folder.
tfms = tfms_from_model(resnet34, sz, crop_type=CropType.NO, tfm_y=TfmType.CLASS, aug_tfms=aug_tfms)
datasets = ImageData.get_ds(MatchedFilesDataset, (trn_x,trn_y), (val_x,val_y), tfms, test = test, path= PATH)
md = ImageData(PATH, datasets, bs, num_workers=16, classes=None)
denorm = md.trn_ds.denorm

And then the error comes out, which is shown as

<ipython-input-100-055d0623841d> in __init__(self, fnames, y, transform, path)
      2     def __init__(self, fnames, y, transform, path):
      3         self.y=y
----> 4         assert(len(fnames)==len(y))
      5         super().__init__(fnames, transform, path)
      6     def get_y(self, i): return open_image(os.path.join(self.path, self.y[i]))
 TypeError: object of type 'PosixPath' has no len()

Can anyone help me with this? As far as I understanding, if the test != None, the MatchedFilesDataset will be called again, but there’s no len() function for the TESTPATH?

It really confuses me :frowning:

Problem solved.