.gitattributes CHANGED
@@ -32,10 +32,3 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
32
  *.zip filter=lfs diff=lfs merge=lfs -text
33
  *.zst filter=lfs diff=lfs merge=lfs -text
34
  *tfevents* filter=lfs diff=lfs merge=lfs -text
35
- results_mapple.png filter=lfs diff=lfs merge=lfs -text
36
- results.png filter=lfs diff=lfs merge=lfs -text
37
- studysites.png filter=lfs diff=lfs merge=lfs -text
38
- testset.png filter=lfs diff=lfs merge=lfs -text
39
- test_sar_images/COL_2011-06-18_TDX_7_1_024_small.png filter=lfs diff=lfs merge=lfs -text
40
- test_sar_images/COL_2016-05-20_TDX_7_1_092_small.png filter=lfs diff=lfs merge=lfs -text
41
- test_sar_images/DBE_2006-02-23_RSAT_12_3_282_small.png filter=lfs diff=lfs merge=lfs -text
 
32
  *.zip filter=lfs diff=lfs merge=lfs -text
33
  *.zst filter=lfs diff=lfs merge=lfs -text
34
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
README.md CHANGED
@@ -1,13 +1,13 @@
1
  ---
2
  title: NnUNet Calvingfront Detection
3
- emoji: 🧊
4
- colorFrom: blue
5
- colorTo: blue
6
  sdk: gradio
7
  sdk_version: 3.27.0
8
  app_file: app.py
9
- pinned: true
10
  license: cc-by-4.0
11
  ---
12
 
13
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
  title: NnUNet Calvingfront Detection
3
+ emoji: 💻
4
+ colorFrom: green
5
+ colorTo: green
6
  sdk: gradio
7
  sdk_version: 3.27.0
8
  app_file: app.py
9
+ pinned: false
10
  license: cc-by-4.0
11
  ---
12
 
13
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py CHANGED
@@ -15,7 +15,6 @@ model_path = 'Task500_Glacier_zonefronts'
15
  def run_front_detection(input_img):
16
  image_gray = input_img.convert("L")
17
  image_gray.save('data_raw/test.png')
18
-
19
  subprocess.run(
20
  ['python3', 'nnunet/dataset_conversion/Task500_Glacier_inference.py', '-data_percentage', '100', '-base',
21
  os.environ['data_raw']])
@@ -29,49 +28,15 @@ def run_front_detection(input_img):
29
  subprocess.run(cmd)
30
  subprocess.run(['python3', 'nnunet/dataset_conversion/Task500_Glacier_reverse.py', '-i',
31
  os.path.join(os.environ['RESULTS_FOLDER'], 'fold_0')])
32
-
33
- front = Image.open(os.path.join(os.environ['RESULTS_FOLDER'], 'tifs/test_front.png'))
34
- zone = Image.open(os.path.join(os.environ['RESULTS_FOLDER'], 'tifs/test_zone.png'))
35
- front = np.array(front)
36
- zone = np.array(zone)
37
-
38
- image_rgb = image_gray.convert('RGB')
39
- image_rgb = np.asarray(image_rgb).copy()
40
-
41
- image_rgb = np.array(image_rgb * 0.5, dtype=np.uint8)
42
- image_rgb[zone[:,:,0] == 0] += np.array(np.array([0, 0, 0]) / 2, dtype=np.uint8)
43
- image_rgb[zone[:,:,0] == 64] += np.array(np.array([52, 46, 55]) / 2, dtype=np.uint8)
44
- image_rgb[zone[:,:,0] == 127] += np.array(np.array([254, 254, 254]) / 2, dtype=np.uint8)
45
- image_rgb[zone[:,:,0] == 254] += np.array(np.array([60, 145, 230]) / 2, dtype=np.uint8)
46
- image_rgb[front[:, :, 0] == 255] = [255, 0, 0]
47
- # Convert NumPy array back to PIL image
48
- pil_image_modified = Image.fromarray(image_rgb)
49
- os.remove(os.path.join(os.environ['RESULTS_FOLDER'],'fold_0/test.nii.gz'))
50
- os.remove(os.path.join(os.environ['RESULTS_FOLDER'], 'tifs/test_front.png'))
51
- os.remove(os.path.join(os.environ['RESULTS_FOLDER'], 'tifs/test_zone.png'))
52
  os.remove('data_raw/test.png')
53
  os.remove('nnUNet_raw_data_base/nnUNet_raw_data/Task500_Glacier_zonefronts/imagesTs/test_0000.nii.gz')
54
 
55
 
56
- return pil_image_modified
57
-
58
- demo = gr.Interface(run_front_detection, gr.Image(type='pil'), "image", title='Calving front detection with nnU-Net',
59
- description="This app can delineate the glacier calving front in radar images from satellites (Sentinal-1, Tan-DEMX, ...). The method is described in \
60
- 'Out-of-the-box calving front detection method using deep-learning' by Herrmann et al.\
61
- https://tc.copernicus.org/preprints/tc-2023-34/. The project was build up on the nnU-Net project \
62
- by Isensee, F., Jaeger, P. F. (2020) https://github.com/MIC-DKFZ/nnUNet and \
63
- and was trained and tested with the dataset of Gourmelon et al. \
64
- https://doi.pangaea.de/10.1594/PANGAEA.940950. <p> <p>\
65
- Drag & Drop a PNG image and click 'Submit' to apply the calving front detection or clock on an example image below. <p> \
66
- For images larger than 200KB we suggest to run on your own PC, this platform providese limited computational resources. <p>\
67
- The output shows an overlay of the segmentation mask generated by the network over the input image. Area of ocean is colored in blue, glacier in white, rock in gray and radar shadow in black.\
68
- The claving front is a thin red line.",
69
- min_height=5000,
70
- examples=[os.path.join(os.path.dirname(__file__), "test_sar_images/Mapple_2018-06-11_S1_20_2_009.png"),
71
- os.path.join(os.path.dirname(__file__), "test_sar_images/COL_2011-06-18_TDX_7_1_024_small.png"),])
72
-
73
-
74
-
75
 
 
76
 
 
77
  demo.launch()
 
15
  def run_front_detection(input_img):
16
  image_gray = input_img.convert("L")
17
  image_gray.save('data_raw/test.png')
 
18
  subprocess.run(
19
  ['python3', 'nnunet/dataset_conversion/Task500_Glacier_inference.py', '-data_percentage', '100', '-base',
20
  os.environ['data_raw']])
 
28
  subprocess.run(cmd)
29
  subprocess.run(['python3', 'nnunet/dataset_conversion/Task500_Glacier_reverse.py', '-i',
30
  os.path.join(os.environ['RESULTS_FOLDER'], 'fold_0')])
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  os.remove('data_raw/test.png')
32
  os.remove('nnUNet_raw_data_base/nnUNet_raw_data/Task500_Glacier_zonefronts/imagesTs/test_0000.nii.gz')
33
 
34
 
35
+ front = Image.open(os.path.join(os.environ['RESULTS_FOLDER'], 'tifs/test_front.png'))
36
+ os.remove(os.path.join(os.environ['RESULTS_FOLDER'],'fold_0/test.nii.gz'))
37
+ os.remove(os.path.join(os.environ['RESULTS_FOLDER'], 'tifs/test_front.png'))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
 
39
+ return front
40
 
41
+ demo = gr.Interface(run_front_detection, gr.Image(type='pil'), "image",interface_size=(1000, 1000))
42
  demo.launch()
nnunet/dataset_conversion/Task500_Glacier_reverse.py CHANGED
@@ -39,19 +39,19 @@ def main(input_folder):
39
  color_zone[glacier_dil == 1] = 127
40
 
41
  color_front = extract_front_from_zones(color_zone, 10)
42
- color_front[color_front==255] = 255
43
 
44
  output_path_zone = join(output_folder, file[:-len('.nii.gz')] + '_zone.png')
45
  output_path_front = join(output_folder, file[:-len('.nii.gz')] + '_front.png')
46
 
47
- #imageio.imwrite(output_path_zone, color_zone)
48
- #imageio.imwrite(output_path_front, color_front)
49
-
50
- img_zone = Image.fromarray(color_zone).convert('RGB')
51
- img_front = Image.fromarray(color_front).convert('RGB')
52
  img_zone.save(output_path_zone)
53
  img_front.save(output_path_front)
54
-
55
 
56
  if __name__ == '__main__':
57
  parser = argparse.ArgumentParser()
 
39
  color_zone[glacier_dil == 1] = 127
40
 
41
  color_front = extract_front_from_zones(color_zone, 10)
42
+ color_front[color_front==255] =1
43
 
44
  output_path_zone = join(output_folder, file[:-len('.nii.gz')] + '_zone.png')
45
  output_path_front = join(output_folder, file[:-len('.nii.gz')] + '_front.png')
46
 
47
+ imageio.imwrite(output_path_zone, color_zone)
48
+ imageio.imwrite(output_path_front, color_front)
49
+ """
50
+ img_zone = Image.fromarray(color_zone)
51
+ img_front = Image.fromarray(color_front)
52
  img_zone.save(output_path_zone)
53
  img_front.save(output_path_front)
54
+ """
55
 
56
  if __name__ == '__main__':
57
  parser = argparse.ArgumentParser()
readme.md CHANGED
@@ -1,4 +1,3 @@
1
- test
2
  # Multi-Task Learning for Glacier Segmentation and Calving Front Prediction with the nnU-Net.
3
 
4
  This project contains the script for the experiments that are described in the paper "Out-of-the-box calving front detection method using deep-learning" by Herrmann et al. https://tc.copernicus.org/preprints/tc-2023-34/
 
 
1
  # Multi-Task Learning for Glacier Segmentation and Calving Front Prediction with the nnU-Net.
2
 
3
  This project contains the script for the experiments that are described in the paper "Out-of-the-box calving front detection method using deep-learning" by Herrmann et al. https://tc.copernicus.org/preprints/tc-2023-34/
results.png DELETED

Git LFS Details

  • SHA256: d44646896d4474bbb464c391c4ec7b849454d0729b82ae7ba00796677421fa25
  • Pointer size: 132 Bytes
  • Size of remote file: 2.54 MB
test_sar_images/COL_2011-06-18_TDX_7_1_024_small.png DELETED
Binary file (263 kB)
 
test_sar_images/Mapple_2018-06-11_S1_20_2_009.png DELETED
Binary file (126 kB)