瀏覽代碼

Update of run simulations

Jérôme BUISINE 5 年之前
父節點
當前提交
639b419169

+ 1 - 0
deep_network_keras_svd.py

@@ -219,6 +219,7 @@ def main():
 
     # Save results obtained from model
     y_test_prediction = model.predict(x_dataset_test)
+    print("Metrics : ", model.metrics_names)
     print("Prediction : ", score)
     print("ROC AUC : ", roc_auc_score(y_dataset_test, y_test_prediction))
 

+ 2 - 0
display_simulation_curves.py

@@ -21,10 +21,12 @@ def display_curves(folder_path, model_name):
     """
 
     for name in models_name:
+        print(name in model_name)
         if name in model_name:
             data_filename = model_name
             learned_zones_folder_path = os.path.join(learned_zones_folder, data_filename)
 
+    print(learned_zones_folder_path)
     data_files = [x for x in os.listdir(folder_path) if '.png' not in x]
 
     scene_names = [f.split('_')[3] for f in data_files]

+ 323 - 0
display_svd_data_error_scene.py

@@ -0,0 +1,323 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+"""
+Created on Fri Sep 14 21:02:42 2018
+
+@author: jbuisine
+"""
+
+from __future__ import print_function
+import sys, os, getopt
+
+import numpy as np
+import random
+import time
+import json
+
+from PIL import Image
+from ipfml import processing, metrics, utils
+import ipfml.iqa.fr as fr_iqa
+
+from skimage import color
+
+import matplotlib.pyplot as plt
+from modules.utils.data import get_svd_data
+
+from modules.utils import config as cfg
+
+# getting configuration information
+config_filename     = cfg.config_filename
+zone_folder         = cfg.zone_folder
+min_max_filename    = cfg.min_max_filename_extension
+
+# define all scenes values
+scenes_list         = cfg.scenes_names
+scenes_indices      = cfg.scenes_indices
+choices             = cfg.normalization_choices
+path                = cfg.dataset_path
+zones               = cfg.zones_indices
+seuil_expe_filename = cfg.seuil_expe_filename
+
+metric_choices      = cfg.metric_choices_labels
+
+max_nb_bits         = 8
+display_error       = False
+
+error_data_choices  = ['mae', 'mse', 'ssim', 'psnr']
+
+
+def get_error_distance(p_error, y_true, y_test):
+
+    noise_method = None
+    function_name = p_error
+
+    try:
+        error_method = getattr(fr_iqa, function_name)
+    except AttributeError:
+        raise NotImplementedError("Error `{}` not implement `{}`".format(fr_iqa.__name__, function_name))
+
+    return error_method(y_true, y_test)
+
+
+def display_svd_values(p_scene, p_interval, p_indices, p_metric, p_mode, p_step, p_norm, p_error, p_ylim):
+    """
+    @brief Method which gives information about svd curves from zone of picture
+    @param p_scene, scene expected to show svd values
+    @param p_interval, interval [begin, end] of svd data to display
+    @param p_interval, interval [begin, end] of samples or minutes from render generation engine
+    @param p_metric, metric computed to show
+    @param p_mode, normalization's mode
+    @param p_norm, normalization or not of selected svd data
+    @param p_error, error metric used to display
+    @param p_ylim, ylim choice to better display of data
+    @return nothing
+    """
+
+    max_value_svd = 0
+    min_value_svd = sys.maxsize
+
+    image_indices = []
+
+    scenes = os.listdir(path)
+    # remove min max file from scenes folder
+    scenes = [s for s in scenes if min_max_filename not in s]
+
+    begin_data, end_data = p_interval
+    begin_index, end_index = p_indices
+
+    data_min_max_filename = os.path.join(path, p_metric + min_max_filename)
+
+    # go ahead each scenes
+    for id_scene, folder_scene in enumerate(scenes):
+
+        if p_scene == folder_scene:
+            scene_path = os.path.join(path, folder_scene)
+
+            config_file_path = os.path.join(scene_path, config_filename)
+
+            with open(config_file_path, "r") as config_file:
+                last_image_name = config_file.readline().strip()
+                prefix_image_name = config_file.readline().strip()
+                start_index_image = config_file.readline().strip()
+                end_index_image = config_file.readline().strip()
+                step_counter = int(config_file.readline().strip())
+
+            # construct each zones folder name
+            zones_folder = []
+
+            # get zones list info
+            for index in zones:
+                index_str = str(index)
+                if len(index_str) < 2:
+                    index_str = "0" + index_str
+
+                current_zone = "zone"+index_str
+                zones_folder.append(current_zone)
+
+            images_data = []
+            images_indices = []
+
+            threshold_learned_zones = []
+
+            for id, zone_folder in enumerate(zones_folder):
+
+                # get threshold information
+
+                zone_path = os.path.join(scene_path, zone_folder)
+                path_seuil = os.path.join(zone_path, seuil_expe_filename)
+
+                # open treshold path and get this information
+                with open(path_seuil, "r") as seuil_file:
+                    threshold_learned = int(seuil_file.readline().strip())
+                    threshold_learned_zones.append(threshold_learned)
+
+            current_counter_index = int(start_index_image)
+            end_counter_index = int(end_index_image)
+
+            threshold_mean = np.mean(np.asarray(threshold_learned_zones))
+            threshold_image_found = False
+
+            file_path = os.path.join(scene_path, prefix_image_name + "{}.png")
+
+            svd_data = []
+
+            while(current_counter_index <= end_counter_index):
+
+                current_counter_index_str = str(current_counter_index)
+
+                while len(start_index_image) > len(current_counter_index_str):
+                    current_counter_index_str = "0" + current_counter_index_str
+
+                image_path = file_path.format(str(current_counter_index_str))
+                img = Image.open(image_path)
+
+                svd_values = get_svd_data(p_metric, img)
+
+                if p_norm:
+                    svd_values = svd_values[begin_data:end_data]
+
+                # update min max values
+                min_value = svd_values.min()
+                max_value = svd_values.max()
+
+                if min_value < min_value_svd:
+                    min_value_svd = min_value
+
+                if max_value > min_value_svd:
+                    max_value_svd = max_value
+
+                # keep in memory used data
+                if current_counter_index % p_step == 0:
+                    if current_counter_index >= begin_index and current_counter_index <= end_index:
+                        images_indices.append(current_counter_index_str)
+                        svd_data.append(svd_values)
+
+                    if threshold_mean < int(current_counter_index) and not threshold_image_found:
+
+                        threshold_image_found = True
+                        threshold_image_zone = current_counter_index_str
+
+                current_counter_index += step_counter
+                print('%.2f%%' % (current_counter_index / end_counter_index * 100))
+                sys.stdout.write("\033[F")
+
+
+            # all indices of picture to plot
+            print(images_indices)
+
+            previous_data = []
+            error_data = [0.]
+
+            for id, data in enumerate(svd_data):
+
+                current_data = data
+
+                if not p_norm:
+                    current_data = current_data[begin_data:end_data]
+
+                if p_mode == 'svdn':
+                    current_data = utils.normalize_arr(current_data)
+
+                if p_mode == 'svdne':
+                    current_data = utils.normalize_arr_with_range(current_data, min_value_svd, max_value_svd)
+
+                images_data.append(current_data)
+
+                # use of whole image data for computation of ssim or psnr
+                if p_error == 'ssim' or p_error == 'psnr':
+                    image_path = file_path.format(str(current_id))
+                    current_data = np.asarray(Image.open(image_path))
+
+                if len(previous_data) > 0:
+
+                    current_error = get_error_distance(p_error, previous_data, current_data)
+                    error_data.append(current_error)
+
+                if len(previous_data) == 0:
+                    previous_data = current_data
+
+            # display all data using matplotlib (configure plt)
+            gridsize = (3, 2)
+
+            # fig, (ax1, ax2) = plt.subplots(nrows=2, ncols=1, figsize=(30, 22))
+            fig = plt.figure(figsize=(30, 22))
+            ax1 = plt.subplot2grid(gridsize, (0, 0), colspan=2, rowspan=2)
+            ax2 = plt.subplot2grid(gridsize, (2, 0), colspan=2)
+
+
+            ax1.set_title(p_scene + ' scene interval information SVD['+ str(begin_data) +', '+ str(end_data) +'], from scenes indices [' + str(begin_index) + ', '+ str(end_index) + '], ' + p_metric + ' metric, ' + p_mode + ', with step of ' + str(p_step) + ', svd norm ' + str(p_norm), fontsize=20)
+            ax1.set_ylabel('Image samples or time (minutes) generation', fontsize=14)
+            ax1.set_xlabel('Vector features', fontsize=16)
+
+            for id, data in enumerate(images_data):
+
+                if display_error:
+                    p_label = p_scene + '_' + str(images_indices[id]) + " | " + p_error + ": " + str(error_data[id])
+                else:
+                    p_label = p_scene + '_' + str(images_indices[id])
+
+                if images_indices[id] == threshold_image_zone:
+                    ax1.plot(data, label=p_label + " (threshold mean)", lw=4, color='red')
+                else:
+                    ax1.plot(data, label=p_label)
+
+            ax1.legend(bbox_to_anchor=(0.7, 1), loc=2, borderaxespad=0.2, fontsize=14)
+
+            start_ylim, end_ylim = p_ylim
+            ax1.set_ylim(start_ylim, end_ylim)
+
+            ax2.set_title(p_error + " information for whole step images")
+            ax2.set_ylabel(p_error + ' error')
+            ax2.set_xlabel('Number of samples per pixels or times')
+            ax2.set_xticks(range(len(images_indices)))
+            ax2.set_xticklabels(list(map(int, images_indices)))
+            ax2.plot(error_data)
+
+            plot_name = p_scene + '_' + p_metric + '_' + str(p_step) + '_' + p_mode + '_' + str(p_norm) + '.png'
+            plt.savefig(plot_name)
+
+def main():
+
+
+    # by default p_step value is 10 to enable all photos
+    p_step = 10
+    p_ylim = (0, 1)
+
+    if len(sys.argv) <= 1:
+        print('Run with default parameters...')
+        print('python display_svd_data_scene.py --scene A --interval "0,800" --indices "0, 900" --metric lab --mode svdne --step 50 --norm 0 --error mae --ylim "0, 0.1"')
+        sys.exit(2)
+    try:
+        opts, args = getopt.getopt(sys.argv[1:], "hs:i:i:z:l:m:s:n:e:y", ["help=", "scene=", "interval=", "indices=", "metric=", "mode=", "step=", "norm=", "error=", "ylim="])
+    except getopt.GetoptError:
+        # print help information and exit:
+        print('python display_svd_data_scene.py --scene A --interval "0,800" --indices "0, 900" --metric lab --mode svdne --step 50 --norm 0 --error mae --ylim "0, 0.1"')
+        sys.exit(2)
+    for o, a in opts:
+        if o == "-h":
+            print('python display_svd_data_scene.py --scene A --interval "0,800" --indices "0, 900" --metric lab --mode svdne --step 50 --norm 0 --error mae --ylim "0, 0.1"')
+            sys.exit()
+        elif o in ("-s", "--scene"):
+            p_scene = a
+
+            if p_scene not in scenes_indices:
+                assert False, "Invalid scene choice"
+            else:
+                p_scene = scenes_list[scenes_indices.index(p_scene)]
+        elif o in ("-i", "--interval"):
+            p_interval = list(map(int, a.split(',')))
+
+        elif o in ("-i", "--indices"):
+            p_indices = list(map(int, a.split(',')))
+
+        elif o in ("-m", "--metric"):
+            p_metric = a
+
+            if p_metric not in metric_choices:
+                assert False, "Invalid metric choice"
+
+        elif o in ("-m", "--mode"):
+            p_mode = a
+
+            if p_mode not in choices:
+                assert False, "Invalid normalization choice, expected ['svd', 'svdn', 'svdne']"
+
+        elif o in ("-s", "--step"):
+            p_step = int(a)
+
+        elif o in ("-n", "--norm"):
+            p_norm = int(a)
+
+        elif o in ("-e", "--error"):
+            p_error = a
+
+        elif o in ("-y", "--ylim"):
+            p_ylim = list(map(float, a.split(',')))
+
+        else:
+            assert False, "unhandled option"
+
+    display_svd_values(p_scene, p_interval, p_indices, p_metric, p_mode, p_step, p_norm, p_error, p_ylim)
+
+if __name__== "__main__":
+    main()

+ 15 - 62
display_svd_data_scene.py

@@ -43,23 +43,8 @@ metric_choices      = cfg.metric_choices_labels
 max_nb_bits         = 8
 display_error       = False
 
-error_data_choices  = ['mae', 'mse', 'ssim', 'psnr']
 
-
-def get_error_distance(p_error, y_true, y_test):
-
-    noise_method = None
-    function_name = p_error
-
-    try:
-        error_method = getattr(fr_iqa, function_name)
-    except AttributeError:
-        raise NotImplementedError("Error `{}` not implement `{}`".format(fr_iqa.__name__, function_name))
-
-    return error_method(y_true, y_test)
-
-
-def display_svd_values(p_scene, p_interval, p_indices, p_metric, p_mode, p_step, p_norm, p_error, p_ylim):
+def display_svd_values(p_scene, p_interval, p_indices, p_metric, p_mode, p_step, p_norm, p_ylim):
     """
     @brief Method which gives information about svd curves from zone of picture
     @param p_scene, scene expected to show svd values
@@ -68,7 +53,6 @@ def display_svd_values(p_scene, p_interval, p_indices, p_metric, p_mode, p_step,
     @param p_metric, metric computed to show
     @param p_mode, normalization's mode
     @param p_norm, normalization or not of selected svd data
-    @param p_error, error metric used to display
     @param p_ylim, ylim choice to better display of data
     @return nothing
     """
@@ -185,9 +169,6 @@ def display_svd_values(p_scene, p_interval, p_indices, p_metric, p_mode, p_step,
             # all indices of picture to plot
             print(images_indices)
 
-            previous_data = []
-            error_data = [0.]
-
             for id, data in enumerate(svd_data):
 
                 current_data = data
@@ -203,55 +184,30 @@ def display_svd_values(p_scene, p_interval, p_indices, p_metric, p_mode, p_step,
 
                 images_data.append(current_data)
 
-                # use of whole image data for computation of ssim or psnr
-                if p_error == 'ssim' or p_error == 'psnr':
-                    image_path = file_path.format(str(current_id))
-                    current_data = np.asarray(Image.open(image_path))
-
-                if len(previous_data) > 0:
-
-                    current_error = get_error_distance(p_error, previous_data, current_data)
-                    error_data.append(current_error)
-
-                if len(previous_data) == 0:
-                    previous_data = current_data
 
             # display all data using matplotlib (configure plt)
-            gridsize = (3, 2)
-
-            # fig, (ax1, ax2) = plt.subplots(nrows=2, ncols=1, figsize=(30, 22))
             fig = plt.figure(figsize=(30, 22))
-            ax1 = plt.subplot2grid(gridsize, (0, 0), colspan=2, rowspan=2)
-            ax2 = plt.subplot2grid(gridsize, (2, 0), colspan=2)
 
+            plt.rc('xtick', labelsize=22)
+            plt.rc('ytick', labelsize=22)
 
-            ax1.set_title(p_scene + ' scene interval information SVD['+ str(begin_data) +', '+ str(end_data) +'], from scenes indices [' + str(begin_index) + ', '+ str(end_index) + '], ' + p_metric + ' metric, ' + p_mode + ', with step of ' + str(p_step) + ', svd norm ' + str(p_norm), fontsize=20)
-            ax1.set_ylabel('Image samples or time (minutes) generation', fontsize=14)
-            ax1.set_xlabel('Vector features', fontsize=16)
+            plt.title(p_scene + ' scene interval information SVD['+ str(begin_data) +', '+ str(end_data) +'], from scenes indices [' + str(begin_index) + ', '+ str(end_index) + '], ' + p_metric + ' metric, ' + p_mode + ', with step of ' + str(p_step) + ', svd norm ' + str(p_norm), fontsize=24)
+            plt.ylabel('Component values', fontsize=24)
+            plt.xlabel('Vector features', fontsize=24)
 
             for id, data in enumerate(images_data):
 
-                if display_error:
-                    p_label = p_scene + '_' + str(images_indices[id]) + " | " + p_error + ": " + str(error_data[id])
-                else:
-                    p_label = p_scene + '_' + str(images_indices[id])
+                p_label = p_scene + '_' + str(images_indices[id])
 
                 if images_indices[id] == threshold_image_zone:
-                    ax1.plot(data, label=p_label + " (threshold mean)", lw=4, color='red')
+                    plt.plot(data, label=p_label + " (threshold mean)", lw=4, color='red')
                 else:
-                    ax1.plot(data, label=p_label)
+                    plt.plot(data, label=p_label)
 
-            ax1.legend(bbox_to_anchor=(0.7, 1), loc=2, borderaxespad=0.2, fontsize=14)
+            plt.legend(bbox_to_anchor=(0.65, 0.98), loc=2, borderaxespad=0.2, fontsize=22)
 
             start_ylim, end_ylim = p_ylim
-            ax1.set_ylim(start_ylim, end_ylim)
-
-            ax2.set_title(p_error + " information for whole step images")
-            ax2.set_ylabel(p_error + ' error')
-            ax2.set_xlabel('Number of samples per pixels or times')
-            ax2.set_xticks(range(len(images_indices)))
-            ax2.set_xticklabels(list(map(int, images_indices)))
-            ax2.plot(error_data)
+            plt.ylim(start_ylim, end_ylim)
 
             plot_name = p_scene + '_' + p_metric + '_' + str(p_step) + '_' + p_mode + '_' + str(p_norm) + '.png'
             plt.savefig(plot_name)
@@ -265,17 +221,17 @@ def main():
 
     if len(sys.argv) <= 1:
         print('Run with default parameters...')
-        print('python display_svd_data_scene.py --scene A --interval "0,800" --indices "0, 900" --metric lab --mode svdne --step 50 --norm 0 --error mae --ylim "0, 0.1"')
+        print('python display_svd_data_scene.py --scene A --interval "0,800" --indices "0, 900" --metric lab --mode svdne --step 50 --norm 0 --ylim "0, 0.1"')
         sys.exit(2)
     try:
         opts, args = getopt.getopt(sys.argv[1:], "hs:i:i:z:l:m:s:n:e:y", ["help=", "scene=", "interval=", "indices=", "metric=", "mode=", "step=", "norm=", "error=", "ylim="])
     except getopt.GetoptError:
         # print help information and exit:
-        print('python display_svd_data_scene.py --scene A --interval "0,800" --indices "0, 900" --metric lab --mode svdne --step 50 --norm 0 --error mae --ylim "0, 0.1"')
+        print('python display_svd_data_scene.py --scene A --interval "0,800" --indices "0, 900" --metric lab --mode svdne --step 50 --norm 0 --ylim "0, 0.1"')
         sys.exit(2)
     for o, a in opts:
         if o == "-h":
-            print('python display_svd_data_scene.py --scene A --interval "0,800" --indices "0, 900" --metric lab --mode svdne --step 50 --norm 0 --error mae --ylim "0, 0.1"')
+            print('python display_svd_data_scene.py --scene A --interval "0,800" --indices "0, 900" --metric lab --mode svdne --step 50 --norm 0 --ylim "0, 0.1"')
             sys.exit()
         elif o in ("-s", "--scene"):
             p_scene = a
@@ -308,16 +264,13 @@ def main():
         elif o in ("-n", "--norm"):
             p_norm = int(a)
 
-        elif o in ("-e", "--error"):
-            p_error = a
-
         elif o in ("-y", "--ylim"):
             p_ylim = list(map(float, a.split(',')))
 
         else:
             assert False, "unhandled option"
 
-    display_svd_values(p_scene, p_interval, p_indices, p_metric, p_mode, p_step, p_norm, p_error, p_ylim)
+    display_svd_values(p_scene, p_interval, p_indices, p_metric, p_mode, p_step, p_norm, p_ylim)
 
 if __name__== "__main__":
     main()

+ 1 - 1
modules/utils/config.py

@@ -37,5 +37,5 @@ 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']
 
-keras_epochs                    = 10
+keras_epochs                    = 500
 keras_batch                     = 32

+ 3 - 2
modules/utils/data.py

@@ -25,7 +25,7 @@ def get_svd_data(data_type, block):
         block.save(block_file_path)
         data = processing.get_LAB_L_SVD_s(Image.open(block_file_path))
 
-    if data_type == 'mscn_revisited':
+    if data_type == 'mscn':
 
         img_mscn_revisited = processing.rgb_to_mscn(block)
 
@@ -38,7 +38,7 @@ def get_svd_data(data_type, block):
         # extract from temp image
         data = metrics.get_SVD_s(img_block)
 
-    if data_type == 'mscn':
+    """if data_type == 'mscn':
 
         img_gray = np.array(color.rgb2gray(np.asarray(block))*255, 'uint8')
         img_mscn = processing.calculate_mscn_coefficients(img_gray, 7)
@@ -47,6 +47,7 @@ def get_svd_data(data_type, block):
         img_mscn_gray = np.array(img_mscn_norm*255, 'uint8')
 
         data = metrics.get_SVD_s(img_mscn_gray)
+    """
 
     if data_type == 'low_bits_6':
 

+ 1 - 1
predict_noisy_image_svd.py

@@ -49,7 +49,7 @@ def main():
     if 'corr' in p_model_file:
         corr_model = True
 
-        indices_corr_path = os.path.join(cfg.correlation_indices_folder, p_model_file.split('/')[1].replace('.json', '') + '.csv')
+        indices_corr_path = os.path.join(cfg.correlation_indices_folder, p_model_file.split('/')[1].replace('.json', '').replace('.joblib', '') + '.csv')
 
         with open(indices_corr_path, 'r') as f:
             data_corr_indices = [int(x) for x in f.readline().split(';') if x != '']

+ 7 - 0
runAll_display_data_scene.sh

@@ -0,0 +1,7 @@
+#! bin/bash
+
+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 scene in {"A","D","G","H"}; do
+        python display_svd_data_scene.py --scene ${scene} --interval "0,800" --indices "0, 2000" --metric ${metric} --mode svdne --step 100 --norm 1 --ylim "0, 0.01"
+    done
+done

+ 1 - 1
runAll_maxwell_custom_corr.sh

@@ -41,7 +41,7 @@ for label in {"0","1"}; do
 
                             echo "${MODEL_NAME} results already generated..."
                         else
-                            python generate_data_model_corr_random.py --output ${FILENAME} --n ${size} --highest ${highest} --label ${label} --kind ${mode} --metric ${metric} --scenes "${scenes}" --nb_zones "${nb_zones}" --percent 1 --renderer "maxwell" --step 10 --random 1
+                            python generate_data_model_corr_random.py --output ${FILENAME} --n ${size} --highest ${highest} --label ${label} --kind ${mode} --metric ${metric} --scenes "${scenes}" --nb_zones "${nb_zones}" --percent 1 --renderer "maxwell" --step 10 --random 1 --custom 1
                             python train_model.py --data ${FILENAME} --output ${MODEL_NAME} --choice ${model}
 
                             # use of interval but it is not really an interval..

+ 1 - 1
runAll_maxwell_keras_corr.sh

@@ -40,7 +40,7 @@ for label in {"0","1"}; do
 
                         echo "${MODEL_NAME} results already generated..."
                     else
-                        python generate_data_model_corr_random.py --output ${FILENAME} --n ${size} --highest ${highest} --label ${label} --kind ${mode} --metric ${metric} --scenes "${scenes}" --nb_zones "${nb_zones}" --percent 1 --renderer "maxwell" --step 10 --random 1
+                        python generate_data_model_corr_random.py --output ${FILENAME} --n ${size} --highest ${highest} --label ${label} --kind ${mode} --metric ${metric} --scenes "${scenes}" --nb_zones "${nb_zones}" --percent 1 --renderer "maxwell" --step 10 --random 1 --custom 1
                         python deep_network_keras_svd.py --data ${FILENAME} --output ${MODEL_NAME} --size ${size}
 
                         # use of interval but it is not really an interval..

+ 54 - 0
runAll_maxwell_keras_corr_custom.sh

@@ -0,0 +1,54 @@
+#! 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
+
+start_index=0
+end_index=24
+
+# selection of four scenes (only maxwell)
+scenes="A, D, G, H"
+metric="lab"
+
+for label in {"0","1"}; do
+    for highest in {"0","1"}; do
+        for nb_zones in {4,6,8,10,12}; do
+            for size in {5,10,15,20,25,30,35,40}; do
+                for mode in {"svd","svdn","svdne"}; do
+
+                    FILENAME="data/deep_keras_N${size}_B${start_index}_E${size}_nb_zones_${nb_zones}_${metric}_${mode}_corr_L${label}_H${highest}"
+                    MODEL_NAME="deep_keras_N${size}_B${start_index}_E${size}_nb_zones_${nb_zones}_${metric}_${mode}_corr_L${label}_H${highest}"
+
+                    echo $FILENAME
+
+                    # only compute if necessary (perhaps server will fall.. Just in case)
+                    if grep -q "${MODEL_NAME}" "${file_path}"; then
+
+                        echo "${MODEL_NAME} results already generated..."
+                    else
+                        python generate_data_model_corr_random.py --output ${FILENAME} --n ${size} --highest ${highest} --label ${label} --kind ${mode} --metric ${metric} --scenes "${scenes}" --nb_zones "${nb_zones}" --percent 1 --renderer "maxwell" --step 10 --random 1
+                        python deep_network_keras_svd.py --data ${FILENAME} --output ${MODEL_NAME} --size ${size}
+
+                        # use of interval but it is not really an interval..
+                        python save_model_result_in_md_maxwell.py --interval "${start_index},${size}" --model "saved_models/${MODEL_NAME}.json" --mode "${mode}" --metric ${metric}
+                    fi
+                done
+            done
+        done
+    done
+done
+

+ 43 - 0
run_maxwell_simulation_corr_custom.sh

@@ -0,0 +1,43 @@
+#! bin/bash
+
+# file which contains model names we want to use for simulation
+simulate_models="simulate_models.csv"
+
+start_index=0
+size=24
+
+# selection of four scenes (only maxwell)
+scenes="A, D, G, H"
+metric="lab"
+
+for label in {"0","1"}; do
+    for highest in {"0","1"}; do
+        for nb_zones in {4,6,8,10,12}; do
+            for size in {5,10,15,20,25,30,35,40}; do
+                for mode in {"svd","svdn","svdne"}; do
+                    for model in {"svm_model","ensemble_model","ensemble_model_v2"}; do
+
+                            FILENAME="data/${model}_N${size}_B${start_index}_E${size}_nb_zones_${nb_zones}_${metric}_${mode}_corr_L${label}_H${highest}"
+                            MODEL_NAME="${model}_N${size}_B${start_index}_E${size}_nb_zones_${nb_zones}_${metric}_${mode}_corr_L${label}_H${highest}"
+                            CUSTOM_MIN_MAX_FILENAME="${model}_N${size}_B${start_index}_E${size}_nb_zones_${nb_zones}_${metric}_${mode}_corr_L${label}_H${highest}_min_max_values"
+
+                            echo ${MODEL_NAME}
+
+                        if grep -xq "${MODEL_NAME}" "${simulate_models}"; then
+                            echo "Run simulation for model ${MODEL_NAME}"
+
+                            python generate_data_model_corr_random.py --output ${FILENAME} --n ${size} --highest ${highest} --label ${label} --kind ${mode} --metric ${metric} --scenes "${scenes}" --nb_zones "${nb_zones}" --percent 1 --renderer "maxwell" --step 10 --random 1 --custom 1
+
+                            python train_model.py --data ${FILENAME} --output ${MODEL_NAME} --choice ${model}
+
+                            python predict_seuil_expe_maxwell_curve.py --interval "${start_index},${size}" --model "saved_models/${MODEL_NAME}.joblib" --mode "${mode}" --metric ${metric} --limit_detection '2' --custom ${CUSTOM_MIN_MAX_FILENAME}
+
+                            python save_model_result_in_md_maxwell.py --interval "${start_index},${size}" --model "saved_models/${MODEL_NAME}.joblib" --mode "${mode}" --metric ${metric}
+
+                        fi
+                    done
+                done
+            done
+        done
+    done
+done

+ 5 - 1
simulate_models.csv

@@ -1 +1,5 @@
-ensemble_model_v2_N4_B0_E4_nb_zones_12_lab_svdne
+ensemble_model_N40_B0_E40_nb_zones_10_lab_svdne_corr_L0_H1
+ensemble_model_N35_B0_E35_nb_zones_12_lab_svdne_corr_L0_H1
+ensemble_model_N40_B0_E40_nb_zones_12_lab_svdne_corr_L0_H1
+svm_model_N25_B0_E25_nb_zones_4_lab_svdne_corr_L0_H1
+ensemble_model_N40_B0_E40_nb_zones_8_lab_svdne_corr_L0_H1