azzenn4 commited on
Commit
1a71d19
·
1 Parent(s): e24a1f4
Files changed (2) hide show
  1. README.md +3 -0
  2. process_patches.py +2 -7
README.md CHANGED
@@ -1,6 +1,9 @@
1
  Dataset for domain shift test in Sen1Floods11 training set, this dataset is manually curated for flood and cloud occlusions test set from WorldFloodsv2.
2
  Based on the paper **Cross-Resolution Domain Shift: From U-Net Encoder–Decoder to the Prithvi Hybrid Model** _Gunawan, A. A. S., Kam, R. M., & Andrew, H._
3
 
 
 
 
4
 
5
  ---
6
 
 
1
  Dataset for domain shift test in Sen1Floods11 training set, this dataset is manually curated for flood and cloud occlusions test set from WorldFloodsv2.
2
  Based on the paper **Cross-Resolution Domain Shift: From U-Net Encoder–Decoder to the Prithvi Hybrid Model** _Gunawan, A. A. S., Kam, R. M., & Andrew, H._
3
 
4
+ Each samples varies in HxW pixel count, refering to `sliding_window_crop()`. Given an image tensor of shape `(C, H, W)`, the function scans across the spatial dimensions in steps of `stride=224`, extracting a `224×224` window at each position.
5
+
6
+ **Edge handling** : When a window would extend beyond the image boundary, the endpoint is clamped to the image edge (`y_end = min(y + 224, H)`), and the start is *recalculated backwards* from that clamped end (`y_start = max(y_end - 224, 0)`). This means the last patch in any row or column overlaps with the second-to-last patch rather than being smaller, every patch is guaranteed to be exactly `224×224`.
7
 
8
  ---
9
 
process_patches.py CHANGED
@@ -47,9 +47,6 @@ os.makedirs(output_root_s2, exist_ok=True)
47
  output_root_gt = "./datasets/Timor_Processed/GT"
48
  os.makedirs(output_root_gt, exist_ok=True)
49
 
50
- output_root_floodmask = "./datasets/Timor_Processed/Floodmask"
51
- os.makedirs(output_root_gt, exist_ok=True)
52
-
53
  def sliding_window_crop(image, window_size=PATCH_SIZE, stride=STRIDE):
54
  C, H, W = image.shape
55
  patches = []
@@ -149,8 +146,7 @@ def plot_label_patches(label_patches, cols=5, save_path=None):
149
  if save_path:
150
  grid_img.save(save_path)
151
 
152
-
153
- # Main processing loop
154
  for tif_path, satellite in files_s2:
155
  print(f"Processing {tif_path} ({satellite})...")
156
  img_tensor = read_tif_as_tensor(tif_path)
@@ -177,8 +173,7 @@ for tif_path, satellite in files_s2:
177
  # plot_label_path = os.path.join(patch_output_dir, f"{base_name}_labels_grid.png")
178
  # plot_label_patches(label_patches, save_path=plot_label_path)
179
 
180
-
181
- # Main processing loop
182
  for tif_path, satellite in files_gt:
183
  print(f"Processing {tif_path} ({satellite})...")
184
  img_tensor = read_tif_as_tensor(tif_path)
 
47
  output_root_gt = "./datasets/Timor_Processed/GT"
48
  os.makedirs(output_root_gt, exist_ok=True)
49
 
 
 
 
50
  def sliding_window_crop(image, window_size=PATCH_SIZE, stride=STRIDE):
51
  C, H, W = image.shape
52
  patches = []
 
146
  if save_path:
147
  grid_img.save(save_path)
148
 
149
+
 
150
  for tif_path, satellite in files_s2:
151
  print(f"Processing {tif_path} ({satellite})...")
152
  img_tensor = read_tif_as_tensor(tif_path)
 
173
  # plot_label_path = os.path.join(patch_output_dir, f"{base_name}_labels_grid.png")
174
  # plot_label_patches(label_patches, save_path=plot_label_path)
175
 
176
+
 
177
  for tif_path, satellite in files_gt:
178
  print(f"Processing {tif_path} ({satellite})...")
179
  img_tensor = read_tif_as_tensor(tif_path)