Datasets:

Languages:
English
Size:
n<1K
License:
srikarym commited on
Commit
af2a55f
·
verified ·
1 Parent(s): ef632b3

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. ZoomLDM-demo-dataset.py +11 -21
ZoomLDM-demo-dataset.py CHANGED
@@ -10,16 +10,16 @@ _N_EMBED = {
10
  "20x": 1,
11
  "10x": 4,
12
  "5x": 16,
13
- "2.5x": 64,
14
- "1.25x": 256,
15
  }
16
 
17
  _MAG_DICT = {
18
- "20x": "20x",
19
- "10x": "10x",
20
- "5x": "5x",
21
- "2.5x": "2.5x",
22
- "1.25x": "1.25x",
23
  }
24
 
25
  _FIXED_SSL_FEATURE_DIM_1 = 1024
@@ -58,7 +58,7 @@ class TCGADataset(datasets.GeneratorBasedBuilder):
58
  VERSION = _DATASET_VERSION
59
  MAGNIFICATIONS = ["20x", "10x", "5x", "2.5x", "1.25x"]
60
  BUILDER_CONFIGS = []
61
- for mag_level_str in MAGNIFICATIONS:
62
  feature_shape = get_ssl_feat_shape(mag_level_str)
63
  builder_config_instance = MagnificationConfig(
64
  name=mag_level_str,
@@ -88,26 +88,18 @@ class TCGADataset(datasets.GeneratorBasedBuilder):
88
  )
89
 
90
  def _split_generators(self, dl_manager):
91
- # self.base_path is set by the datasets library to the directory
92
- # of the original script when loading a local script file.
93
- # e.g., if script is at './zoomldm_data/ZoomLDM-demo-dataset.py',
94
- # self.base_path will be the absolute path to './zoomldm_data/'
95
- if not self.base_path:
96
- # This should not happen when loading a local script file directly
97
- raise ValueError("Dataset Builder's base_path is not set. Cannot locate local data.")
98
 
99
  original_script_dir = Path(self.base_path)
100
  mag_folder_name = self.config.data_dir
101
 
102
- # Construct the absolute path to the 'data/magnification_folder_name'
103
- # relative to the original script's directory.
104
  mag_data_abs_path = original_script_dir / "data" / mag_folder_name
105
 
106
  return [
107
  datasets.SplitGenerator(
108
  name=datasets.Split.TRAIN,
109
  gen_kwargs={
110
- "mag_folder_abs_path": mag_data_abs_path, # Pass the absolute Path object
111
  "mag_level": self.config.mag_level,
112
  },
113
  ),
@@ -127,10 +119,8 @@ class TCGADataset(datasets.GeneratorBasedBuilder):
127
  processed_feature = preprocess_features(ssl_feat_data)
128
 
129
  yield idx, {
130
- "image": str(img_path), # datasets.Image() handles path strings
131
  "ssl_feat": processed_feature,
132
- "filename_img": img_filename,
133
- "filename_feat": feat_filename,
134
  "mag": _MAG_DICT[mag_level],
135
  }
136
  idx += 1
 
10
  "20x": 1,
11
  "10x": 4,
12
  "5x": 16,
13
+ "2_5x": 64,
14
+ "1_25x": 256,
15
  }
16
 
17
  _MAG_DICT = {
18
+ "20x": 0,
19
+ "10x": 1,
20
+ "5x": 2,
21
+ "2_5x": 3,
22
+ "1_25x": 4,
23
  }
24
 
25
  _FIXED_SSL_FEATURE_DIM_1 = 1024
 
58
  VERSION = _DATASET_VERSION
59
  MAGNIFICATIONS = ["20x", "10x", "5x", "2.5x", "1.25x"]
60
  BUILDER_CONFIGS = []
61
+ for mag_level_str in _MAG_DICT.keys():
62
  feature_shape = get_ssl_feat_shape(mag_level_str)
63
  builder_config_instance = MagnificationConfig(
64
  name=mag_level_str,
 
88
  )
89
 
90
  def _split_generators(self, dl_manager):
91
+
 
 
 
 
 
 
92
 
93
  original_script_dir = Path(self.base_path)
94
  mag_folder_name = self.config.data_dir
95
 
 
 
96
  mag_data_abs_path = original_script_dir / "data" / mag_folder_name
97
 
98
  return [
99
  datasets.SplitGenerator(
100
  name=datasets.Split.TRAIN,
101
  gen_kwargs={
102
+ "mag_folder_abs_path": mag_data_abs_path,
103
  "mag_level": self.config.mag_level,
104
  },
105
  ),
 
119
  processed_feature = preprocess_features(ssl_feat_data)
120
 
121
  yield idx, {
122
+ "image": str(img_path),
123
  "ssl_feat": processed_feature,
 
 
124
  "mag": _MAG_DICT[mag_level],
125
  }
126
  idx += 1