Upload EuroSAT.py with huggingface_hub
Browse files- EuroSAT.py +12 -16
EuroSAT.py
CHANGED
|
@@ -38,9 +38,9 @@ class EuroSATConfig(datasets.BuilderConfig):
|
|
| 38 |
|
| 39 |
def update(self, **kwargs):
|
| 40 |
"""Update Config"""
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
|
| 45 |
class EuroSAT(datasets.GeneratorBasedBuilder):
|
| 46 |
VERSION = datasets.Version("1.0.0")
|
|
@@ -57,19 +57,15 @@ class EuroSAT(datasets.GeneratorBasedBuilder):
|
|
| 57 |
HEIGHT = WIDTH = 64
|
| 58 |
|
| 59 |
def __init__(self, *args, **kwargs):
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
config = EuroSATConfig(**config_kwargs)
|
| 69 |
-
kwargs['config'] = config
|
| 70 |
|
| 71 |
-
for k in config_kwargs:
|
| 72 |
-
kwargs.pop(k, None)
|
| 73 |
|
| 74 |
self.height = self.HEIGHT
|
| 75 |
self.width = self.WIDTH
|
|
@@ -85,7 +81,7 @@ class EuroSAT(datasets.GeneratorBasedBuilder):
|
|
| 85 |
"River",
|
| 86 |
"SeaLake",
|
| 87 |
]
|
| 88 |
-
self.num_channels = len(
|
| 89 |
super().__init__(*args, **kwargs)
|
| 90 |
# if 'config' in kwargs:
|
| 91 |
# user_config = kwargs['config']
|
|
|
|
| 38 |
|
| 39 |
def update(self, **kwargs):
|
| 40 |
"""Update Config"""
|
| 41 |
+
super().update(**kwargs)
|
| 42 |
+
if 'bands' in kwargs:
|
| 43 |
+
self.band_indices = [int(self.all_band_names.index(b)) for b in self.bands if b in self.all_band_names]
|
| 44 |
|
| 45 |
class EuroSAT(datasets.GeneratorBasedBuilder):
|
| 46 |
VERSION = datasets.Version("1.0.0")
|
|
|
|
| 57 |
HEIGHT = WIDTH = 64
|
| 58 |
|
| 59 |
def __init__(self, *args, **kwargs):
|
| 60 |
+
config = kwargs.pop('config', None)
|
| 61 |
+
|
| 62 |
+
# Initialize config first
|
| 63 |
+
if config:
|
| 64 |
+
if isinstance(config, dict):
|
| 65 |
+
for key, value in config.items():
|
| 66 |
+
if key in ['bands']:
|
| 67 |
+
kwargs[key] = value
|
|
|
|
|
|
|
| 68 |
|
|
|
|
|
|
|
| 69 |
|
| 70 |
self.height = self.HEIGHT
|
| 71 |
self.width = self.WIDTH
|
|
|
|
| 81 |
"River",
|
| 82 |
"SeaLake",
|
| 83 |
]
|
| 84 |
+
self.num_channels = len(self.config.band_indices)
|
| 85 |
super().__init__(*args, **kwargs)
|
| 86 |
# if 'config' in kwargs:
|
| 87 |
# user_config = kwargs['config']
|