Parcourir la source

Update of projects caused by new version of ipfml

Jérôme BUISINE il y a 5 ans
Parent
commit
1706b563ef

+ 3 - 4
generate_all_data.py

@@ -15,8 +15,7 @@ import json
 
 from modules.utils.data_type import get_svd_data
 from PIL import Image
-from ipfml import processing
-from ipfml import metrics
+from ipfml import processing, metrics, utils
 from skimage import color
 
 from modules.utils import config as cfg
@@ -141,10 +140,10 @@ def generate_data_svd(data_type, color, mode):
                                 min_val = float(f.readline())
                                 max_val = float(f.readline())
 
-                            data = processing.normalize_arr_with_range(data, min_val, max_val)
+                            data = utils.normalize_arr_with_range(data, min_val, max_val)
 
                         if mode == 'svdn':
-                            data = processing.normalize_arr(data)
+                            data = utils.normalize_arr(data)
 
                         # save min and max found from dataset in order to normalize data using whole data known
                         if mode == 'svd':

+ 2 - 11
generate_all_noise.sh

@@ -7,7 +7,8 @@ for file in "images"/*; do
 
     image=${ADDR[1]%".png"}
 
-    for noise in {"cauchy","gaussian","laplace","log_normal","mut_white","white"}; do
+
+    for noise in {"cauchy","gaussian","laplace","log_normal","mut_white","white","salt_pepper"}; do
 
         for identical in {"0","1"}; do
 
@@ -19,14 +20,4 @@ for file in "images"/*; do
 
         done
     done
-
-
-    # specific for salt and pepper noise
-    for identical in {"0","1"}; do
-        if [ ${identical} == "1" ]; then
-            python noise_computation.py --noise salt_pepper --image ${file} --n 1000 --identical ${identical} --output ${image}_salt_pepper.png --step 10 --all 1 --p 0.1 &
-        else
-            python noise_computation.py --noise salt_pepper --image ${file} --n 1000 --identical ${identical} --output ${image}_salt_pepper_color.png --step 10 --all 1 --p 0.1 &
-        fi
-    done
 done

+ 2 - 2
generate_data_model_random.py

@@ -14,7 +14,7 @@ import time
 import json
 
 from PIL import Image
-from ipfml import processing, metrics
+from ipfml import processing, metrics, utils
 
 from modules.utils import config as cfg
 from modules.utils import data as dt
@@ -54,7 +54,7 @@ def construct_new_line(path_seuil, interval, line, norm):
 
     # TODO : check if it's always necessary to do that (loss of information for svd)
     if norm:
-        metrics = processing.normalize_arr_with_range(metrics, min_value_interval, max_value_interval)
+        metrics = utils.normalize_arr_with_range(metrics, min_value_interval, max_value_interval)
 
     with open(path_seuil, "r") as seuil_file:
         seuil_learned = int(seuil_file.readline().strip())

+ 30 - 9
generate_noise_all_curves.sh

@@ -11,20 +11,41 @@ for file in "images"/*; do
     if [ "$image" != "calibration" ] || [ "$image" != *"min_max_values"* ]; then
 
         #for metric in {"lab","mscn_revisited","low_bits_2","low_bits_3","low_bits_4","low_bits_5","low_bits_6","low_bits_4_shifted_2"}; do
-        for metric in {"lab","low_bits_4","low_bits_5","low_bits_4_shifted_2"}; do
+        for metric in {"lab","low_bits_5","low_bits_4_shifted_2"}; do
             for noise in {"cauchy","gaussian","laplace","log_normal","mut_white","white","salt_pepper"}; do
                 for mode in {"svdn","svdne"}; do
                     for error in {"MAE","MSE"}; do
 
-                        #echo "${image}_${metric}_${noise}_${mode}_${error}_norm0" >> output_test.txt
-                        #echo "${image}_${metric}_${noise}_${mode}_${error}_norm1" >> output_test.txt
-                        #echo "${image}_${metric}_${noise}_${mode}_${error}_norm0_color" >> output_test.txt
-                        #echo "${image}_${metric}_${noise}_${mode}_${error}_norm1_color" >> output_test.txt
+                        filename_prefix="${image}_${noise}_1_to_1000_B30_E800_${metric}_S30_norm"
+                        filename_suffix="_${mode}_${error}"
 
-                        python noise_svd_tend_visualization.py  --prefix generated/${image}/${noise} --metric ${metric} --n 1000 --mode ${mode} --interval "0, 800" --step 40 --norm 0 --ylim "0, 0.05" --error ${error}
-                        python noise_svd_tend_visualization.py  --prefix generated/${image}/${noise} --metric ${metric} --n 1000 --mode ${mode} --interval "0, 800" --step 40 --norm 1 --ylim "0, 0.1" --error ${error}
-                        python noise_svd_tend_visualization.py  --prefix generated/${image}/${noise} --metric ${metric} --n 1000 --mode ${mode} --interval "0, 800" --step 40 --norm 0 --color 1 --ylim "0, 0.05" --error ${error}
-                        python noise_svd_tend_visualization.py  --prefix generated/${image}/${noise} --metric ${metric} --n 1000 --mode ${mode} --interval "0, 800" --step 40 --norm 1 --color 1 --ylim "0, 0.1" --error ${error}
+                        if [ ! -f "curves_pictures/${filename_prefix}0${filename_suffix}.png" ]; then
+
+                            python noise_svd_tend_visualization.py  --prefix generated/${image}/${noise} --metric ${metric} --n 1000 --mode ${mode} --interval "30, 800" --step 30 --norm 0 --ylim "0, 0.05" --error ${error}
+                        else
+                            echo "Already generated.."
+                        fi
+
+                        if [ ! -f "curves_pictures/${filename_prefix}1${filename_suffix}.png" ]; then
+                            python noise_svd_tend_visualization.py  --prefix generated/${image}/${noise} --metric ${metric} --n 1000 --mode ${mode} --interval "30, 800" --step 30 --norm 1 --ylim "0, 0.1" --error ${error}
+                        else
+                            echo "Already generated.."
+                        fi
+
+
+                        if [ ! -f "curves_pictures/${filename_prefix}0${filename_suffix}_color.png" ]; then
+                            python noise_svd_tend_visualization.py  --prefix generated/${image}/${noise} --metric ${metric} --n 1000 --mode ${mode} --interval "30, 800" --step 30 --norm 0 --color 1 --ylim "0, 0.05" --error ${error}
+                        else
+                            echo "Already generated.."
+                        fi
+
+                        if [ ! -f "curves_pictures/${filename_prefix}1${filename_suffix}_color.png" ]; then
+                            python noise_svd_tend_visualization.py  --prefix generated/${image}/${noise} --metric ${metric} --n 1000 --mode ${mode} --interval "30, 800" --step 30 --norm 1 --color 1 --ylim "0, 0.1" --error ${error}
+
+                        else
+                            echo "Already generated.."
+
+                        fi
                     done
                 done
             done

+ 5 - 5
noise_svd_tend_visualization.py

@@ -1,7 +1,7 @@
 import sys, os, getopt
 from PIL import Image
 
-from ipfml import processing
+from ipfml import processing, utils
 
 from modules.utils import config as cfg
 from modules.utils import data_type as dt
@@ -159,10 +159,10 @@ def main():
 
             current_data = data
             if p_mode == 'svdn':
-                current_data = processing.normalize_arr(current_data)
+                current_data = utils.normalize_arr(current_data)
 
             if p_mode == 'svdne':
-                current_data = processing.normalize_arr_with_range(current_data, min_value_svd, max_value_svd)
+                current_data = utils.normalize_arr_with_range(current_data, min_value_svd, max_value_svd)
 
             svd_data.append(current_data)
             image_indices.append(current_id)
@@ -182,7 +182,7 @@ def main():
     ax1 = plt.subplot2grid(gridsize, (0, 0), colspan=2, rowspan=2)
     ax2 = plt.subplot2grid(gridsize, (2, 0), colspan=2)
 
-    ax1.set_title(p_prefix  + ' noise, interval information ['+ str(begin) +', '+ str(end) +'], ' + p_metric + ' metric, step ' + str(p_step) + ' normalization ' + p_mode)
+    ax1.set_title(p_prefix  + ', ' + noise_name + ' noise, interval information ['+ str(begin) +', '+ str(end) +'], ' + p_metric + ' metric, step ' + str(p_step) + ' normalization ' + p_mode)
     ax1.set_label('Importance of noise [1, 999]')
     ax1.set_xlabel('Vector features')
 
@@ -191,7 +191,7 @@ def main():
         p_label = p_prefix + str(image_indices[id]) + " | MAE : " + str(error_data[id])
         ax1.plot(data, label=p_label)
 
-    ax1.legend(bbox_to_anchor=(0, 1), loc=2, borderaxespad=0.2, fontsize=12)
+    ax1.legend(bbox_to_anchor=(0.8, 1), loc=2, borderaxespad=0.2, fontsize=12)
 
     if not p_norm:
         ax1.set_xlim(begin, end)

+ 3 - 3
noise_svd_visualization.py

@@ -1,7 +1,7 @@
 import sys, os, getopt
 from PIL import Image
 
-from ipfml import processing
+from ipfml import processing, utils
 
 from modules.utils import config as cfg
 from modules.utils import data_type as dt
@@ -120,10 +120,10 @@ def main():
 
             current_data = data
             if p_mode == 'svdn':
-                current_data = processing.normalize_arr(current_data)
+                current_data = utils.normalize_arr(current_data)
 
             if p_mode == 'svdne':
-                current_data = processing.normalize_arr_with_range(current_data, min_value_svd, max_value_svd)
+                current_data = utils.normalize_arr_with_range(current_data, min_value_svd, max_value_svd)
 
             svd_data.append(current_data)
             image_indices.append(str(id * step_picture))