Explorar el Código

Add of new metric : ipca diff

Jérôme BUISINE hace 5 años
padre
commit
9f01428ed1

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 315 - 0
analysis/svd_ipca_scenes_analysis.ipynb


+ 1 - 1
modules/utils/config.py

@@ -35,7 +35,7 @@ cycle_scenes_indices            = ['E', 'I']
 normalization_choices           = ['svd', 'svdn', 'svdne']
 zones_indices                   = np.arange(16)
 
-metric_choices_labels           = ['lab', 'mscn', 'low_bits_2', 'low_bits_3', 'low_bits_4', 'low_bits_5', 'low_bits_6','low_bits_4_shifted_2', 'sub_blocks_stats', 'sub_blocks_area', 'sub_blocks_stats_reduced', 'sub_blocks_area_normed', 'mscn_var_4', 'mscn_var_16', 'mscn_var_64', 'mscn_var_16_max', 'mscn_var_64_max', 'ica_diff', 'svd_trunc_diff']
+metric_choices_labels           = ['lab', 'mscn', 'low_bits_2', 'low_bits_3', 'low_bits_4', 'low_bits_5', 'low_bits_6','low_bits_4_shifted_2', 'sub_blocks_stats', 'sub_blocks_area', 'sub_blocks_stats_reduced', 'sub_blocks_area_normed', 'mscn_var_4', 'mscn_var_16', 'mscn_var_64', 'mscn_var_16_max', 'mscn_var_64_max', 'ica_diff', 'svd_trunc_diff', 'ipca_diff']
 
 keras_epochs                    = 500
 keras_batch                     = 32

+ 14 - 0
modules/utils/data.py

@@ -4,6 +4,7 @@ from modules.utils.config import *
 from PIL import Image
 from skimage import color
 from sklearn.decomposition import FastICA
+from sklearn.decomposition import IncrementalPCA
 from sklearn.decomposition import TruncatedSVD
 
 import numpy as np
@@ -234,6 +235,19 @@ def get_svd_data(data_type, block):
         U, s, V = metrics.get_SVD(reduced_image)
         data = s
 
+    if data_type == 'ipca_diff':
+
+        current_image = metrics.get_LAB_L(block)
+
+        transformer = IncrementalPCA(n_components=20, batch_size=25)
+        transformed_image = transformer.fit_transform(current_image)
+        restored_image = transformer.inverse_transform(transformed_image)
+
+        reduced_image = (current_image - restored_image)
+
+        U, s, V = metrics.get_SVD(reduced_image)
+        data = s
+
     return data
 
 def _get_mscn_variance(block, sub_block_size=(50, 50)):

+ 1 - 1
runAll_maxwell_custom.sh

@@ -18,7 +18,7 @@ fi
 
 for size in {"4","8","16","26","32","40"}; do
 
-    for metric in {"lab","mscn","low_bits_2","low_bits_3","low_bits_4","low_bits_5","low_bits_6","low_bits_4_shifted_2","ica_diff","svd_trunc_diff"}; do
+    for metric in {"lab","mscn","low_bits_2","low_bits_3","low_bits_4","low_bits_5","low_bits_6","low_bits_4_shifted_2","ica_diff","svd_trunc_diff","ipca_diff"}; do
         bash generateAndTrain_maxwell_custom.sh ${size} ${metric}
     done
 done

+ 1 - 1
runAll_maxwell_custom_center.sh

@@ -18,7 +18,7 @@ fi
 
 for size in {"4","8","16","26","32","40"}; do
 
-    for metric in {"lab","mscn","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","mscn","low_bits_2","low_bits_3","low_bits_4","low_bits_5","low_bits_6","low_bits_4_shifted_2","ica_diff","svd_trunc_diff","ipca_diff"}; do
         bash generateAndTrain_maxwell_custom_center.sh ${size} ${metric}
     done
 done

+ 1 - 1
runAll_maxwell_custom_split.sh

@@ -18,7 +18,7 @@ fi
 
 for size in {"4","8","16","26","32","40"}; do
 
-    for metric in {"lab","mscn","low_bits_2","low_bits_3","low_bits_4","low_bits_5","low_bits_6","low_bits_4_shifted_2","ica_diff","svd_trunc_diff"}; do
+    for metric in {"lab","mscn","low_bits_2","low_bits_3","low_bits_4","low_bits_5","low_bits_6","low_bits_4_shifted_2","ica_diff","svd_trunc_diff","ipca_diff"}; do
         bash generateAndTrain_maxwell_custom_split.sh ${size} ${metric}
     done
 done