From f03642c4d1bb64e6d399f1819d1b4ff8daa3c497 Mon Sep 17 00:00:00 2001
From: Maciej Wielgosz <maciej.wielgosz@nibio.no>
Date: Sat, 17 Dec 2022 12:57:30 +0100
Subject: [PATCH] update sematic seg. sean with switch off flag for removal of
 small tiles

---
 bash_helper_scripts/get_test_corrected.sh |  8 ++++++
 optimization_pipeline/sem_seg_sean.sh     | 30 ++++++++++++++++-------
 2 files changed, 29 insertions(+), 9 deletions(-)
 create mode 100755 bash_helper_scripts/get_test_corrected.sh

diff --git a/bash_helper_scripts/get_test_corrected.sh b/bash_helper_scripts/get_test_corrected.sh
new file mode 100755
index 0000000..67adabf
--- /dev/null
+++ b/bash_helper_scripts/get_test_corrected.sh
@@ -0,0 +1,8 @@
+#!/bin/bash
+
+TARGET_FOLDER=/home/nibio/mutable-outside-world/code/gitlab_fsct/instance_segmentation_classic/sample_playground
+# clean the folder
+rm -rf $TARGET_FOLDER/*
+
+cp /home/nibio/mutable-outside-world/data/corrected/test/*.las $TARGET_FOLDER
+
diff --git a/optimization_pipeline/sem_seg_sean.sh b/optimization_pipeline/sem_seg_sean.sh
index 962c376..74b1f12 100755
--- a/optimization_pipeline/sem_seg_sean.sh
+++ b/optimization_pipeline/sem_seg_sean.sh
@@ -7,14 +7,19 @@ CONDA_ENV="pdal-env-1" # conda environment for running the pipeline
 
 # Tiling parameters
 data_folder="" # path to the folder containing the data
+remove_small_tiles=0 # 1: remove small tiles, 0: not remove small tiles
 
 ############################# end of parameters declaration ############################
 
 # extract tiling parameters as command line arguments with the same default values
-while getopts "d:" opt; do
+
+# add remove_small_tiles parameter
+while getopts "d:z:" opt; do
   case $opt in
     d) data_folder="$OPTARG"
     ;;
+    z) remove_small_tiles="$OPTARG"
+    ;;
     \?) echo "Invalid option -$OPTARG" >&2
     ;;
   esac
@@ -27,6 +32,7 @@ echo "d: data_folder"
 # print values of the parameters 
 echo "      The values of the parameters:"
 echo "data_folder: $data_folder"
+echo "remove_small_tiles: $remove_small_tiles"
 
 # Do the environment setup
 # check if PYTHONPATH is set to the current directory
@@ -108,14 +114,20 @@ python nibio_preprocessing/tiling.py \
 --tile_size 10
 
 # remove small tiles using nibio_preprocessing/remove_small_tiles.py
-for d in $data_folder/segmented_point_clouds/tiled/*; do
-    echo "Removing small tiles from $d"
-    python nibio_preprocessing/remove_small_tiles.py \
-    --dir $d \
-    --tile_index $d/tile_index.dat \
-    --min_density 75 \
-    --verbose
-done
+
+# make it conditional bassed remove_small_tiles parameter
+if  [ $remove_small_tiles -eq 1 ]
+then
+    # iterate over all the directories in the tiled folder
+    for d in $data_folder/segmented_point_clouds/tiled/*; do
+        echo "Removing small tiles from $d"
+        python nibio_preprocessing/remove_small_tiles.py \
+        --dir $d \
+        --tile_index $d/tile_index.dat \
+        --min_density 75 \
+        --verbose
+    done
+fi
 
 # iterate over all the directories in the tiled folder
 for d in $data_folder/segmented_point_clouds/tiled/*/; do
-- 
GitLab