Skip to content

Commit

Permalink
formatting fix
Browse files Browse the repository at this point in the history
  • Loading branch information
isaaccorley committed Aug 2, 2021
1 parent 69d8647 commit 39aae8a
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 15 deletions.
4 changes: 2 additions & 2 deletions torchrs/datasets/eurosat.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class EuroSATRGB(ImageFolder):
""" Sentinel-2 RGB Land Cover Classification dataset from 'EuroSAT: A Novel Dataset
and Deep Learning Benchmark for Land Use and Land Cover Classification', Helber at al. (2017)
https://arxiv.org/abs/1709.00029
'We present a novel dataset based on Sentinel-2 satellite images covering 13 spectral
bands and consisting out of 10 classes with in total 27,000 labeled and geo-referenced images.'
Expand All @@ -32,7 +32,7 @@ class EuroSATMS(ImageFolder):
""" Sentinel-2 RGB Land Cover Classification dataset from 'EuroSAT: A Novel Dataset
and Deep Learning Benchmark for Land Use and Land Cover Classification', Helber at al. (2017)
https://arxiv.org/abs/1709.00029
'We present a novel dataset based on Sentinel-2 satellite images covering 13 spectral
bands and consisting out of 10 classes with in total 27,000 labeled and geo-referenced images.'
Expand Down
3 changes: 2 additions & 1 deletion torchrs/datasets/fair1m.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
from glob import glob
from xml.etree import ElementTree
from typing import List, Dict, Tuple
from typing import List, Dict

import torch
import numpy as np
Expand Down Expand Up @@ -74,6 +74,7 @@ class FAIR1M(torch.utils.data.Dataset):
"Intersection": {"id": 35, "category": "Road"},
"Bridge": {"id": 36, "category": "Road"}
}

def __init__(
self,
root: str = ".data/fair1m",
Expand Down
2 changes: 1 addition & 1 deletion torchrs/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@


__all__ = [
"RAMS", "EarlyFusion", "FCEF", "FCSiamConc", "FCSiamDiff"
"RAMS", "EarlyFusion", "Siam", "FCEF", "FCSiamConc", "FCSiamDiff"
]
3 changes: 1 addition & 2 deletions torchrs/models/fc_cd.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ def forward(self, x: torch.Tensor) -> Tuple[torch.Tensor, torch.Tensor]:
return self.pool(x), x



class DeConvBlock(nn.Sequential):

def __init__(self, filters: List[int], kernel_size: int = 3, dropout: float = 0.2):
Expand Down Expand Up @@ -154,7 +153,7 @@ def forward(self, x: torch.Tensor) -> torch.Tensor:

# Concat skips
skips = [rearrange(skip, "(b t) c h w -> b (t c) h w", t=t) for skip in skips]

# Only first input encoding is passed directly to decoder
x = rearrange(x, "(b t) c h w -> b t c h w", t=t)
x = x[:, 0, ...]
Expand Down
10 changes: 4 additions & 6 deletions torchrs/models/oscd.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ class EarlyFusion(nn.Module):
def __init__(self, channels: int = 3, t: int = 2, num_classes: int = 2):
super().__init__()
filters = [channels * t, 32, 32, 64, 64, 128, 128]
kernel_size = 3
dropout = 0.2
self.encoder = nn.Sequential(
*[ConvBlock(filters[i-1], filters[i]) for i in range(1, len(filters))],
Expand All @@ -35,9 +34,9 @@ def __init__(self, channels: int = 3, t: int = 2, num_classes: int = 2):
)
self.mlp = nn.Sequential(
nn.Linear(128, 8),
nn.BatchNorm1d(8),
nn.BatchNorm1d(8),
nn.ReLU(),
nn.Dropout2d(dropout),
nn.Dropout2d(dropout),
nn.Linear(8, num_classes)
)

Expand All @@ -60,17 +59,16 @@ class Siam(nn.Module):
def __init__(self, channels: int = 3, t: int = 2, num_classes: int = 2):
super().__init__()
filters = [channels, 64, 64, 128]
kernel_size = 3
dropout = 0.2
self.encoder = nn.Sequential(
*[ConvBlock(filters[i-1], filters[i]) for i in range(1, len(filters))],
ConvBlock(filters[-1], 128, dropout=0.0),
)
self.mlp = nn.Sequential(
nn.Linear(t*128*7*7, 64),
nn.BatchNorm1d(64),
nn.BatchNorm1d(64),
nn.ReLU(),
nn.Dropout2d(dropout),
nn.Dropout2d(dropout),
nn.Linear(64, num_classes)
)

Expand Down
2 changes: 0 additions & 2 deletions torchrs/models/rams.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
""" Referenced from official TF implementation https://github.com/EscVM/RAMS/blob/master/utils/network.py """
import math

import torch
import torch.nn as nn
from einops import rearrange
Expand Down
2 changes: 1 addition & 1 deletion torchrs/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def __call__(self, x: np.ndarray) -> torch.Tensor:


class ToDtype(object):

def __init__(self, dtype: torch.dtype):
self.dtype = dtype

Expand Down

0 comments on commit 39aae8a

Please sign in to comment.