Skip to content
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

Fix example jupyter notebook #70

Closed
jvincent131 opened this issue Apr 27, 2023 · 1 comment · Fixed by #72
Closed

Fix example jupyter notebook #70

jvincent131 opened this issue Apr 27, 2023 · 1 comment · Fixed by #72
Assignees
Labels
bug Something isn't working

Comments

@jvincent131
Copy link

Example notebook 03_example_widebandsig53_dataset give an error AttributeError: module 'torchsig.transforms.transforms' has no attribute 'Spectrogram'

@sei-cabidi
Copy link

sei-cabidi commented Apr 28, 2023

I ran into this issue as well. Looks like the authors are aware of the problems according to issues #60 and #47. I switched to the v0.2.0 branch and changed the first two cells to the following. Note the removal of ST. before Spectrogram, Normalize, and DescToBBoxSignalDict.

import numpy as np
from tqdm import tqdm
import matplotlib.pyplot as plt
from torch.utils.data import DataLoader

import torchsig
import torchsig.models
from torchsig.models.spectrogram_models import detr_b0_nano
import torchsig.transforms as ST
from torchsig.transforms.transforms import *
from torchsig.transforms.signal_processing.sp import *
from torchsig.transforms.expert_feature.eft import *
from torchsig.transforms.target_transforms.target_transforms import *
from torchsig.datasets.wideband_sig53 import WidebandSig53

and

# Specify WidebandSig53 Options
root = 'wideband_sig53/'
train = True
impaired = False
fft_size = 512
num_classes = 1

transform = Compose([
    Spectrogram(nperseg=fft_size, noverlap=0, nfft=fft_size, mode='complex'),
    Normalize(norm=np.inf, flatten=True),
])

target_transform = Compose([
    DescToBBoxSignalDict(),
])

# Instantiate the training WidebandSig53 Dataset
wideband_sig53_train = WidebandSig53(
    root=root, 
    train=train, 
    impaired=impaired,
    transform=transform,
    target_transform=target_transform,
    regenerate=False,
    use_signal_data=True,
    gen_batch_size=1,
    use_gpu=True,
)

# Instantiate the validation WidebandSig53 Dataset
train = False
wideband_sig53_val = WidebandSig53(
    root=root, 
    train=train, 
    impaired=impaired,
    transform=transform,
    target_transform=target_transform,
    regenerate=False,
    use_signal_data=True,
    gen_batch_size=1,
    use_gpu=True,
)

# Retrieve a sample and print out information
idx = 0
data, label = wideband_sig53_val[idx]
print("Training Dataset length: {}".format(len(wideband_sig53_train)))
print("Validation Dataset length: {}".format(len(wideband_sig53_val)))
print("Data shape: {}".format(data.shape))
print("Label: {}".format(label))

Hopefully this can help you make some progress until a fix is pushed.

@TorchDSP TorchDSP self-assigned this May 2, 2023
@TorchDSP TorchDSP added the bug Something isn't working label May 2, 2023
@gvanhoy gvanhoy linked a pull request May 2, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants