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

tensor2image and dataloder length #2595

Open
wangjiawen2013 opened this issue Dec 8, 2024 · 1 comment
Open

tensor2image and dataloder length #2595

wangjiawen2013 opened this issue Dec 8, 2024 · 1 comment

Comments

@wangjiawen2013
Copy link
Contributor

wangjiawen2013 commented Dec 8, 2024

Hi,
I have two questions now

  1. In pytorch, we can convert tensors to images and save on disk using from torchvision.utils import save_image. How to convert a tensor to image and save it on disk using burn ?
  2. In pytorch, we can get batch numbers using len(dataloader). How to get the batch numbers in a dataloader in burn ? It seems that dataloader.num_items only returns the total number of samples, not the batch number.
@laggui
Copy link
Member

laggui commented Dec 9, 2024

  1. There is no utility similar to the pytorch vision extension for save_image in Burn atm. But this should be fairly straightforward using the tensor data and constructing an image buffer to save (e.g., Rgb32FImage)
  2. The DataLoader trait doesn't expose the number of batches in a dataloader. It returns an iterator to iterate over the batches any fixed-size assumption. The dataloader length can only be known for a fixed-size dataset, so even pytorch makes assumption for different dataset types and might report inaccurate length (as in their disclaimer). So for now we chose not to make any assumptions 🙂

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

2 participants