jonathan-roberts1 commited on
Commit
ba0402e
1 Parent(s): 04cbbba

Ensure image is first feature

Browse files
Files changed (1) hide show
  1. SATIN.py +7 -21
SATIN.py CHANGED
@@ -7,11 +7,9 @@ _CONSTITUENT_DATASETS = ['SAT-4', 'SAT-6', 'NASC-TG2', 'WHU-RS19', 'RSSCN7', 'RS
7
  'Airbus-Wind-Turbines-Patches', 'USTC_SmokeRS', 'Canadian_Cropland',
8
  'Ships-In-Satellite-Imagery', 'Satellite-Images-of-Hurricane-Damage',
9
  'Brazilian_Coffee_Scenes', 'Brazilian_Cerrado-Savanna_Scenes', 'Million-AID',
10
- 'UC_Merced_LandUse_MultiLabel', 'MLRSNet',
11
  'MultiScene', 'RSI-CB256']
12
- """
13
- _CONSTITUENT_DATASETS = ['EuroSAT']
14
- """
15
 
16
  class SATINConfig(datasets.BuilderConfig):
17
  """BuilderConfig for SATIN"""
@@ -24,38 +22,22 @@ class SATINConfig(datasets.BuilderConfig):
24
  self.description = None
25
  self.features = None
26
 
27
- #stream_dataset_info = load_dataset(self.hf_dataset_name, streaming=True, split='train').info
28
- #self.description = stream_dataset_info.description
29
- #self.features = stream_dataset_info.features
30
-
31
 
32
  class SATIN(datasets.GeneratorBasedBuilder):
33
  """SATIN Images dataset"""
34
 
35
  BUILDER_CONFIGS = [SATINConfig(name=dataset_name) for dataset_name in _CONSTITUENT_DATASETS]
36
 
37
- """
38
- def __init__(self, *args, **kwargs):
39
- super().__init__(*args, **kwargs)
40
- self.config.hf_dataset = load_dataset(self.config.hf_dataset_name)
41
- self.config.description = self.config.hf_dataset['train'].description
42
- self.config.features = self.config.hf_dataset['train'].features
43
- print(self.config.features)
44
- """
45
-
46
  def _info(self):
47
  if self.config.description is None or self.config.features is None:
48
  stream_dataset_info = load_dataset(self.config.hf_dataset_name, streaming=True, split='train').info
49
  self.config.description = stream_dataset_info.description
50
  self.config.features = stream_dataset_info.features
51
- #print(f'info {self.config.features}')
52
  return datasets.DatasetInfo(
53
  description=self.config.description,
54
  features=self.config.features,
55
- #supervised_keys=("image", "label"),
56
  )
57
 
58
-
59
  def _split_generators(self, dl_manager):
60
  dataset = load_dataset(self.config.hf_dataset_name)
61
  return [
@@ -71,7 +53,11 @@ class SATIN(datasets.GeneratorBasedBuilder):
71
  huggingface_dataset = data_path['train']
72
  features = huggingface_dataset.features
73
  for idx, row in enumerate(huggingface_dataset):
74
- yield idx, {feature: row[feature] for feature in features}
 
 
 
 
75
 
76
 
77
 
 
7
  'Airbus-Wind-Turbines-Patches', 'USTC_SmokeRS', 'Canadian_Cropland',
8
  'Ships-In-Satellite-Imagery', 'Satellite-Images-of-Hurricane-Damage',
9
  'Brazilian_Coffee_Scenes', 'Brazilian_Cerrado-Savanna_Scenes', 'Million-AID',
10
+ 'UC_Merced_LandUse_MultiLabel', 'MLRSNet',
11
  'MultiScene', 'RSI-CB256']
12
+
 
 
13
 
14
  class SATINConfig(datasets.BuilderConfig):
15
  """BuilderConfig for SATIN"""
 
22
  self.description = None
23
  self.features = None
24
 
 
 
 
 
25
 
26
  class SATIN(datasets.GeneratorBasedBuilder):
27
  """SATIN Images dataset"""
28
 
29
  BUILDER_CONFIGS = [SATINConfig(name=dataset_name) for dataset_name in _CONSTITUENT_DATASETS]
30
 
 
 
 
 
 
 
 
 
 
31
  def _info(self):
32
  if self.config.description is None or self.config.features is None:
33
  stream_dataset_info = load_dataset(self.config.hf_dataset_name, streaming=True, split='train').info
34
  self.config.description = stream_dataset_info.description
35
  self.config.features = stream_dataset_info.features
 
36
  return datasets.DatasetInfo(
37
  description=self.config.description,
38
  features=self.config.features,
 
39
  )
40
 
 
41
  def _split_generators(self, dl_manager):
42
  dataset = load_dataset(self.config.hf_dataset_name)
43
  return [
 
53
  huggingface_dataset = data_path['train']
54
  features = huggingface_dataset.features
55
  for idx, row in enumerate(huggingface_dataset):
56
+ features_dict = {feature: row[feature] for feature in features}
57
+ # Reorder features to make image the first feature
58
+ image = features_dict.pop('image')
59
+ features_dict = {'image': image, **features_dict}
60
+ yield idx, features_dict
61
 
62
 
63