-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeError When Using TensorAudio Batch Transforms #23
Comments
I think the issue is probably due to Can you add this code right after the imports and see if it resolves the issue? from fastxtend.transform import BatchRandTransform
def call_fix(self,
b:Tensor|tuple[Tensor,...], # Batch item(s)
split_idx:int|None = None, # Train (0) or valid (1) index
**kwargs
) -> Tensor|tuple[Tensor,...]:
"Call `super().__call__` if `self.do`"
self.before_call(b, split_idx=split_idx)
return super().__call__(b, split_idx=split_idx, **kwargs) if self.do else b
BatchRandTransform.__call__ = call_fix The audio_fixes branch was merged in #18. I forgot to delete it. |
Thanks that works! This code: auds = DataBlock(blocks = (AudioBlock, CategoryBlock),
get_x = ColReader("filename", pref=path/"audio"/"audio"),
splitter = ColSplitter(),
get_y = ColReader("category"),
batch_tfms = PitchShift())
auds.summary(df) Now outputs the expected result: Note that I was running into the following error when using your fix: when running So I modified the def call_fix(self,
b:Tensor|tuple[Tensor,...], # Batch item(s)
split_idx:int|None = None, # Train (0) or valid (1) index
**kwargs
) -> Tensor|tuple[Tensor,...]:
"Call `super().__call__` if `self.do`"
self.before_call(b, split_idx=split_idx)
return super(BatchRandTransform, self).__call__(b, split_idx=split_idx, **kwargs) if self.do else b
BatchRandTransform.__call__ = call_fix |
@vishalbakshi can you check that #24 resolves this issue? If so, I will merge it and cut a release. |
First off, thanks for such an awesome library, I'm using it for the first time and really enjoying it.
I am running into a
TypeError
when using one of the TensorAudio batch transforms (VolumeBatch
,PitchShift
,TimeStretch
,PitchShiftOrTimeStretch
) when callingauds.summary
whereauds
is theDataBlock
.I am using fastxtend version
0.1.7
and fastai version2.7.14
on Kaggle.I have created a reproducible example in this Kaggle Notebook. I chose to use Kaggle so that I can easily incorporate an audio classification dataset in the example.
In short, when I run the following code in that notebook:
I get the error:
I don't get this error when using the different item transforms (
Flip
,Roll
,Volume
, etc.) I also tried using fastai's built-inaug_transforms
andRandomResizedCropGPU
asbatch_tfms
and while it obviously doesn't do anything to the TensorAudio,auds.summary
runs without error.I looked at the source code for
PitchShift
andsplit_idx
is defined at the top.I also saw that there is an
audio_fixes
branch open so perhaps this is already a known issue. I'm not proficient at the internals of fastai, but am happy to help troubleshoot this issue if you can point me in a general direction of where to start looking. Or, perhaps I'm implementing it wrong and that's why I'm getting this error.The text was updated successfully, but these errors were encountered: