question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ExtractTensorPatches for Masks in AugmentationSequential

See original GitHub issue

🚀 Feature

Modify kornia.contrib.ExtractTensorPatches to apply the same operation to masks in AugmentationSequential.

Motivation

In remote sensing it’s common to work with imagery which can be relatively large in shape (e.g. 3000x3000+). Therefore during training images are broken into patches. For segmentation tasks it’s needed to apply the same patch extract operation to both images and masks.

Pitch

Modify kornia.contrib.ExtractTensorPatches to apply the same operation to masks in AugmentationSequential.

Alternatives

If there is a better way to chain augmentations and ExtractTensorPatches please provide suggestions.

Additional context

import torch
import kornia.augmentation as K
from kornia.contrib import ExtractTensorPatches

image = torch.randn(2, 3, 128, 128)
mask = torch.randn(2, 1, 128, 128)

augs = K.AugmentationSequential(
    K.ColorJitter(0.1, 0.1, 0.1, 0.1, p=1.0),
    K.RandomAffine(360, p=1.0),
    ExtractTensorPatches(window_size=32, stride=32, padding=0),
    data_keys=["input", "mask"]
)
image, mask = augs(image, mask)

# NotImplementedError: data_key DataKey.MASK is not implemented for ExtractTensorPatches().

@adamjstewart @calebrob6

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:12 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
shijianjiancommented, Oct 8, 2021

Hi @isaaccorley, please checkout #1347.

Then, the required operation can be implemented as

PatchExtractor = LambdaAugmentation.from_modules(
    kornia.contrib.ExtractTensorPatches(),
    inverse_module=kornia.contrib.CombineTensorPatches(),
    for_data_keys=["input", "mask"],
)

Please comment on the PR if any 😃

1reaction
isaaccorleycommented, Sep 24, 2021

I think lambda makes sense here and helps support chaining other general ops in a AugmentationSequential container.

Read more comments on GitHub >

github_iconTop Results From Across the Web

kornia.augmentation.container.augment - Read the Docs
[docs]class AugmentationSequential(ImageSequential): r"""AugmentationSequential for handling multiple input types like inputs, masks, keypoints at once.
Read more >
Masks: COVID-19 - MN Dept. of Health
The masking recommendations below include these CDC considerations and additional MDH considerations for people who are immunocompromised or at higher risk of ...
Read more >
Issues-kornia/kornia - PythonTechWorld
ExtractTensorPatches to apply the same operation to masks in AugmentationSequential. Motivation In remote sensing it's common to work with imagery which can ...
Read more >
Wearing Masks in Travel and Public Transportation Settings
Wearing a high-quality mask or respirator is most beneficial in crowded or poorly ventilated locations, such as airport jetways. CDC also encourages operators ......
Read more >
kornia - bytemeta
ExtractTensorPatches for Masks in AugmentationSequential. isaaccorley. isaaccorley CLOSED · Updated 1 year ago · Inverse of Extract Tensor Patches. lyhyl.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found