Hey! nice job with this library!
I’m trying to use load_learner with a test set to make predictions, but I’m not able to.
I would like to do something like:
some_audio_item_list= AudioItemList.from_XXX()
learn = load_learner(path, model_name, test=some_audio_item_list)
let me add that
some_audio_item_list.items
returns
array(['../input/test/000ccb97.wav', '../input/test/0012633b.wav', '../input/test/001ed5f1.wav',
'../input/test/00294be0.wav', ..., '../input/test/41f86bc4.wav', '../input/test/4215309a.wav',
'../input/test/4248d196.wav', '../input/test/42542036.wav'], dtype=object)
which is what I expect to.
The error I have is:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-270-e3b4c8a83f0f> in <module>()
8 #learn = load_learner(DATA, 'models-sound/' + model, test=test)
9 test_audios=AudioItemList.from_df(df=test_df, path=WORK, cols=2, using_librosa=True)
---> 10 learn = load_learner("../working", model, test=test_audios)
11
12 preds, _ = learn.TTA(ds_type=DatasetType.Test)
/opt/conda/lib/python3.6/site-packages/fastai/basic_train.py in load_learner(path, file, test, **db_kwargs)
593 model = state.pop('model')
594 src = LabelLists.load_state(path, state.pop('data'))
--> 595 if test is not None: src.add_test(test)
596 data = src.databunch(**db_kwargs)
597 cb_state = state.pop('cb_state')
/opt/conda/lib/python3.6/site-packages/fastai/data_block.py in add_test(self, items, label)
550 if isinstance(items, ItemList): items = self.valid.x.new(items.items, inner_df=items.inner_df).process()
551 else: items = self.valid.x.new(items).process()
--> 552 self.test = self.valid.new(items, labels)
553 return self
554
/opt/conda/lib/python3.6/site-packages/fastai/data_block.py in new(self, x, y, **kwargs)
616 def new(self, x, y, **kwargs)->'LabelList':
617 if isinstance(x, ItemList):
--> 618 return self.__class__(x, y, tfms=self.tfms, tfm_y=self.tfm_y, **self.tfmargs)
619 else:
620 return self.new(self.x.new(x, **kwargs), self.y.new(y, **kwargs)).process()
/opt/conda/lib/python3.6/site-packages/fastai/data_block.py in __init__(self, x, y, tfms, tfm_y, **kwargs)
589 self.y.x = x
590 self.item=None
--> 591 self.transform(tfms, **kwargs)
592
593 def __len__(self)->int: return len(self.x) if self.item is None else 1
/opt/conda/lib/python3.6/site-packages/fastai/data_block.py in transform(self, tfms, tfm_y, **kwargs)
707 def transform(self, tfms:TfmList, tfm_y:bool=None, **kwargs):
708 "Set the `tfms` and `tfm_y` value to be applied to the inputs and targets."
--> 709 _check_kwargs(self.x, tfms, **kwargs)
710 if tfm_y is None: tfm_y = self.tfm_y
711 if tfm_y: _check_kwargs(self.y, tfms, **kwargs)
/opt/conda/lib/python3.6/site-packages/fastai/data_block.py in _check_kwargs(ds, tfms, **kwargs)
578 if (tfms is None or len(tfms) == 0) and len(kwargs) == 0: return
579 if len(ds.items) >= 1:
--> 580 x = ds[0]
581 try: x.apply_tfms(tfms, **kwargs)
582 except Exception as e:
/opt/conda/lib/python3.6/site-packages/fastai/data_block.py in __getitem__(self, idxs)
107 def __getitem__(self,idxs:int)->Any:
108 idxs = try_int(idxs)
--> 109 if isinstance(idxs, Integral): return self.get(idxs)
110 else: return self.new(self.items[idxs], inner_df=index_row(self.inner_df, idxs))
111
<ipython-input-234-334a3dbe8fad> in get(self, i)
81 def get(self, i):
82 fn = super().get(i)
---> 83 return open_audio(fn, using_librosa=self.using_librosa, downsampling=self.downsampling)
84
85
<ipython-input-233-ef0065fe2480> in open_audio(fn, using_librosa, downsampling)
73 def open_audio(fn, using_librosa:bool=True, downsampling=8000):
74 if using_librosa:
---> 75 x, sr = librosa.core.load(fn, sr=None, mono=False)
76
77 else:
/opt/conda/lib/python3.6/site-packages/librosa/core/audio.py in load(path, sr, mono, offset, duration, dtype, res_type)
117
118 y = []
--> 119 with audioread.audio_open(os.path.realpath(path)) as input_file:
120 sr_native = input_file.samplerate
121 n_channels = input_file.channels
/opt/conda/lib/python3.6/posixpath.py in realpath(filename)
385 """Return the canonical path of the specified filename, eliminating any
386 symbolic links encountered in the path."""
--> 387 filename = os.fspath(filename)
388 path, ok = _joinrealpath(filename[:0], filename, {})
389 return abspath(path)
TypeError: expected str, bytes or os.PathLike object, not numpy.int64
Any help is appreciated!