Skip to content

SignBank loading: SignWriting: "AttributeError: 'numpy.ndarray' object has no attribute 'decode'" #70

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

Open
cleong110 opened this issue May 30, 2024 · 4 comments

Comments

@cleong110
Copy link
Contributor

This snippet from the example Colab notebook causes an AttributeError.

signbank = tfds.load(name='sign_bank')

for datum in itertools.islice(signbank["train"], 0, 10):
  print(datum['id'].numpy().decode('utf-8'), datum['sign_writing'].numpy().decode('utf-8'), [f.decode('utf-8') for f in datum['terms'].numpy()])

Rewriting it to be three print statements localizes to sign_writing

image

It seems this is because that is actually an array of shape (1,), rather than being bytes. Taking the first element, THEN calling decode works
image

Compare rwth-phoenix-weather-2014t

image

@cleong110
Copy link
Contributor Author

Checking the first 5k data in the dataset, it seems there can be 0, 1, or 2 items.

image

Looking at the source code, we also see that the Feature is a Sequence
https://github.com/sign-language-processing/datasets/blob/master/sign_language_datasets/datasets/signbank/signbank.py#L198

@cleong110
Copy link
Contributor Author

I wonder if we can make it so that the library just automatically detects internally if it's a Sequence and prints accordingly?

@cleong110
Copy link
Contributor Author

cleong110 commented May 30, 2024

The quick fix for this issue would be to simply edit the example notebook with a note, maybe something like:

signbank = tfds.load(name='sign_bank')

for datum in itertools.islice(signbank["train"], 0, 10):
  print(datum['id'].numpy().decode('utf-8'))
  for signwriting_item in datum["sign_writing"]: # This feature is a Sequence of strings
    print(signwriting_item.numpy().decode('utf-8'))
  print([f.decode('utf-8') for f in datum['terms'].numpy()])

@cleong110
Copy link
Contributor Author

My notebook where I test downloading SignBank: https://colab.research.google.com/drive/1hs_UjwKv_mMxZvtittI4AD--SA6cpT5k?usp=sharing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant