Closed ArthDh closed 4 years ago
Hi @ArthDh
If you want to use Cutout
with PIL you could use torchtoolbox.cutout.Cutout_PIL
.
Best, Devin.
It would be nice if we could have just one Cutout function that could handle both PIL and CV images!
It's a good idea but need more if else
and convert code
, which could make code run slower.
Also I have plans to Integrate with albumentations
, it would be better when this finished.
We could just do a type check and call the function as needed there would be no need to convert the image in that case. Integration with albumentations
sounds good!
If you have good idea please make a pr to me.
pytorch-lightning==0.7.6 torchtoolbox==0.1.4.1 torchvision==0.6.0a0+82fd1c8
Loading Images using:
img = Image.open(str(IMAGE_DIR ))) # import PIL.Image as Image
Composing Transforms using:
Trace: AttributeError: Caught AttributeError in DataLoader worker process 0. Original Traceback (most recent call last): File "/opt/conda/lib/python3.7/site-packages/torch/utils/data/_utils/worker.py", line 178, in _worker_loop data = fetcher.fetch(index) File "/opt/conda/lib/python3.7/site-packages/torch/utils/data/_utils/fetch.py", line 44, in fetch data = [self.dataset[idx] for idx in possibly_batched_index] File "/opt/conda/lib/python3.7/site-packages/torch/utils/data/_utils/fetch.py", line 44, in
data = [self.dataset[idx] for idx in possibly_batched_index]
File "", line 30, in getitem
img = self.transform(img)
File "/opt/conda/lib/python3.7/site-packages/torchvision/transforms/transforms.py", line 61, in call
img = t(img)
File "/opt/conda/lib/python3.7/site-packages/torchtoolbox/transform/transforms.py", line 1450, in call
left, top, h, w, ch = self.get_params(img, self.scale, self.ratio)
File "/opt/conda/lib/python3.7/site-packages/torchtoolbox/transform/transforms.py", line 1433, in get_params
img_h, img_w, img_c = img.shape
AttributeError: 'Image' object has no attribute 'shape'