Przeglądaj źródła

Merge branch 'release/v0.2.8'

Jérôme BUISINE 5 lat temu
rodzic
commit
d9f8b176f2

Plik diff jest za duży
+ 37 - 8
analysis/svd_ica_scenes_analysis.ipynb


Plik diff jest za duży
+ 68 - 15
analysis/svd_reconstruction_analysis.ipynb


Plik diff jest za duży
+ 1 - 1
modules/utils/config.py


+ 64 - 2
modules/utils/data.py

@@ -11,6 +11,7 @@ from numpy.linalg import svd as lin_svd
 from scipy.signal import medfilt2d, wiener, cwt
 import pywt
 
+import cv2
 import numpy as np
 
 
@@ -364,6 +365,67 @@ def get_svd_data(data_type, block):
         # data are arranged following std trend computed
         data = s_arr[indices]
 
+    if 'filters_statistics' in data_type:
+
+        img_width, img_height = 200, 200
+
+        lab_img = metrics.get_LAB_L(block)
+        arr = np.array(lab_img)
+
+        # compute all filters statistics
+        def get_stats(arr, I_filter):
+
+            e1       = np.abs(arr - I_filter)
+            L        = np.array(e1)
+            mu0      = np.mean(L)
+            A        = L - mu0
+            H        = A * A
+            E        = np.sum(H) / (img_width * img_height)
+            P        = np.sqrt(E)
+
+            return mu0, P
+
+        stats = []
+
+        kernel = np.ones((3,3),np.float32)/9
+        stats.append(get_stats(arr, cv2.filter2D(arr,-1,kernel)))
+
+        kernel = np.ones((5,5),np.float32)/25
+        stats.append(get_stats(arr, cv2.filter2D(arr,-1,kernel)))
+
+        stats.append(get_stats(arr, cv2.GaussianBlur(arr, (3, 3), 0.5)))
+
+        stats.append(get_stats(arr, cv2.GaussianBlur(arr, (3, 3), 1)))
+
+        stats.append(get_stats(arr, cv2.GaussianBlur(arr, (3, 3), 1.5)))
+
+        stats.append(get_stats(arr, cv2.GaussianBlur(arr, (5, 5), 0.5)))
+
+        stats.append(get_stats(arr, cv2.GaussianBlur(arr, (5, 5), 1)))
+
+        stats.append(get_stats(arr, cv2.GaussianBlur(arr, (5, 5), 1.5)))
+
+        stats.append(get_stats(arr, medfilt2d(arr, [3, 3])))
+
+        stats.append(get_stats(arr, medfilt2d(arr, [5, 5])))
+
+        stats.append(get_stats(arr, wiener(arr, [3, 3])))
+
+        stats.append(get_stats(arr, wiener(arr, [5, 5])))
+
+        wave = w2d(arr, 'db1', 2)
+        stats.append(get_stats(arr, np.array(wave, 'float64')))
+
+        data = []
+
+        for stat in stats:
+            data.append(stat[0])
+
+        for stat in stats:
+            data.append(stat[1])
+        
+        data = np.array(data)
+
     return data
 
 
@@ -378,7 +440,7 @@ def get_lowest_values(arr, n):
 def w2d(arr, mode='haar', level=1):
     #convert to float   
     imArray = arr
-    imArray /= 255
+    np.divide(imArray, 255)
 
     # compute coefficients 
     coeffs=pywt.wavedec2(imArray, mode, level=level)
@@ -388,7 +450,7 @@ def w2d(arr, mode='haar', level=1):
     coeffs_H[0] *= 0
 
     # reconstruction
-    imArray_H = pywt.waverec2(coeffs_H, mode);
+    imArray_H = pywt.waverec2(coeffs_H, mode)
     imArray_H *= 255
     imArray_H = np.uint8(imArray_H)
 

+ 22 - 0
runAll_maxwell_custom_filters_stats.sh

@@ -0,0 +1,22 @@
+#! bin/bash
+
+# erase "models_info/models_comparisons.csv" file and write new header
+file_path='models_info/models_comparisons.csv'
+
+erased=$1
+
+if [ "${erased}" == "Y" ]; then
+    echo "Previous data file erased..."
+    rm ${file_path}
+    mkdir -p models_info
+    touch ${file_path}
+
+    # add of header
+    echo 'model_name; vector_size; start; end; nb_zones; metric; mode; tran_size; val_size; test_size; train_pct_size; val_pct_size; test_pct_size; train_acc; val_acc; test_acc; all_acc; F1_train; recall_train; roc_auc_train; F1_val; recall_val; roc_auc_val; F1_test; recall_test; roc_auc_test; F1_all; recall_all; roc_auc_all;' >> ${file_path}
+
+fi
+
+size=26
+metric="filters_statistics"
+
+bash generateAndTrain_maxwell_custom_filters.sh ${size} ${metric} &

+ 22 - 0
runAll_maxwell_custom_filters_stats_center.sh

@@ -0,0 +1,22 @@
+#! bin/bash
+
+# erase "models_info/models_comparisons.csv" file and write new header
+file_path='models_info/models_comparisons.csv'
+
+erased=$1
+
+if [ "${erased}" == "Y" ]; then
+    echo "Previous data file erased..."
+    rm ${file_path}
+    mkdir -p models_info
+    touch ${file_path}
+
+    # add of header
+    echo 'model_name; vector_size; start; end; nb_zones; metric; mode; tran_size; val_size; test_size; train_pct_size; val_pct_size; test_pct_size; train_acc; val_acc; test_acc; all_acc; F1_train; recall_train; roc_auc_train; F1_val; recall_val; roc_auc_val; F1_test; recall_test; roc_auc_test; F1_all; recall_all; roc_auc_all;' >> ${file_path}
+
+fi
+
+size=26
+metric="filters_statistics"
+
+bash generateAndTrain_maxwell_custom_filters_center.sh ${size} ${metric} &

+ 22 - 0
runAll_maxwell_custom_filters_stats_split.sh

@@ -0,0 +1,22 @@
+#! bin/bash
+
+# erase "models_info/models_comparisons.csv" file and write new header
+file_path='models_info/models_comparisons.csv'
+
+erased=$1
+
+if [ "${erased}" == "Y" ]; then
+    echo "Previous data file erased..."
+    rm ${file_path}
+    mkdir -p models_info
+    touch ${file_path}
+
+    # add of header
+    echo 'model_name; vector_size; start; end; nb_zones; metric; mode; tran_size; val_size; test_size; train_pct_size; val_pct_size; test_pct_size; train_acc; val_acc; test_acc; all_acc; F1_train; recall_train; roc_auc_train; F1_val; recall_val; roc_auc_val; F1_test; recall_test; roc_auc_test; F1_all; recall_all; roc_auc_all;' >> ${file_path}
+
+fi
+
+size=26
+metric="filters_statistics"
+
+bash generateAndTrain_maxwell_custom_filters_split.sh ${size} ${metric} &