Skip to content

Commit

Permalink
Remove preprocess
Browse files Browse the repository at this point in the history
  • Loading branch information
ashnair1 committed Apr 11, 2023
1 parent a49669c commit 377c699
Showing 1 changed file with 1 addition and 33 deletions.
34 changes: 1 addition & 33 deletions torchgeo/datamodules/vhr10.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@

import kornia.augmentation as K
import torch
import torchvision
from einops import rearrange
from torch import Generator, Tensor
from torch.nn.modules import Module
from torch.nn import Module
from torch.utils.data import random_split

from ..datasets import VHR10
Expand Down Expand Up @@ -139,37 +138,6 @@ def __init__(
batch_size,
)

self.kwargs["download"] = True

def preprocess(self, sample: Dict[str, Any]) -> Dict[str, Any]:
"""Transform a single sample from the Dataset.
Args:
sample: input image dictionary
Returns:
preprocessed sample
"""
sample["image"] = sample["image"].float()

_, h, w = sample["image"].shape
sample["image"] = torchvision.transforms.functional.resize(
sample["image"], size=self.patch_size
)
box_scale = (self.patch_size[1] / w, self.patch_size[0] / h)
sample["boxes"][:, 0] *= box_scale[0]
sample["boxes"][:, 1] *= box_scale[1]
sample["boxes"][:, 2] *= box_scale[0]
sample["boxes"][:, 3] *= box_scale[1]
sample["boxes"] = torch.round(sample["boxes"])

if "masks" in sample:
sample["masks"] = torchvision.transforms.functional.resize(
sample["masks"], size=self.patch_size
)

return sample

def setup(self, stage: str) -> None:
"""Set up datasets.
Expand Down

0 comments on commit 377c699

Please sign in to comment.