Incompatibility to pytorch: Some transformations return lists for singe Image
See original GitHub issueThe pipeline is not compatible with pytorch because the operations return lists [ <PIL.Image.Image image mode=L size=28x28 at 0x7F4C6F113A90>] but expect as input: <PIL.Image.Image image mode=L size=28x28 at 0x7F4C6F113A90>
Here a minimalistic example, where I show what the MNIST dataloader does internally and why it fails…
import Augmentor
from torchvision import datasets, transforms
from torch.utils import data
loader = data.DataLoader(datasets.MNIST('./../data', download=True, transform=transforms.Compose([transforms.ToTensor()])))
p1 = Augmentor.Pipeline()
p1.zoom(probability=1, min_factor=1.1, max_factor=1.5)
p1 = p1.torch_transform()
p2 = Augmentor.Pipeline()
p2.shear(probability=1, max_shear_left=5, max_shear_right=5)
p2 = p2.torch_transform()
# test it
for i, (batch, label) in enumerate(loader):
batch = transforms.ToPILImage()(batch[0])
batch = p1(batch)
print(batch) # prints [<PIL.Image.Image image mode=L size=28x28 at 0x7F4BE1BF9470>]
batch = p2(batch) # expects list --> fails, works if I do p2(batch[0])
print('batch', batch)
break
Issue Analytics
- State:
- Created 5 years ago
- Comments:5
Top Results From Across the Web
Incompatibility to pytorch: Some transformations return lists for singe ...
The pipeline is not compatible with pytorch because the operations return lists [ ] but expect as input: Here a minimalistic example, where...
Read more >Transforming and augmenting images - PyTorch
Most transformations accept both PIL images and tensor images, although some transformations are PIL-only and some are tensor-only.
Read more >torchvision.transforms — Torchvision master documentation
Parameters: transforms (list of Transform objects) – list of transforms to ... This transform returns a tuple of images and there may be...
Read more >Transforms — MONAI 1.1.0 Documentation
Return a Composition with a simple list of transforms, as opposed to any nested Compositions. ... requires pytorch >= 1.10 for best compatibility....
Read more >Data Augmentation in PyTorch - Stack Overflow
Crop the given image into four corners and the central crop. This transform returns a tuple of images and there may be a...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
workaround:
Hi~ Is this problem fixed?