Bladeren bron

Merge branch 'release/v0.1.7'

Jérôme BUISINE 6 jaren geleden
bovenliggende
commit
f20bf4eac0

+ 8 - 7
README.md

@@ -33,16 +33,17 @@ python generate_all_data.py --metric mscn --step 50
 
 - **fichiersSVD_light/\*** : all scene files information (zones of each scene, SVD descriptor files information and so on...).
 - **models/*.py** : all models developed to predict noise in image.
-- **utils/** : contains all usefull script or modules.
 - **data/\*** : folder which will contain all *.train* & *.test* files in order to train model.
 - **saved_models/*.joblib** : all scikit learn models saved.
-- **models_info/*.md** : all markdown files generated to get quick information about model performance and prediction.
+- **models_info/*** : all markdown files generated to get quick information about model performance and prediction. This folder contains also **model_comparisons.csv** obtained after running runAll_maxwell.sh script.
+- **modules/\*** : contains all modules usefull for the whole project (such as configuration variables)
 
 ### Scripts for generating data files
 
 Two scripts can be used for generating data in order to fit model :
 - **generate_data_model.py** : zones are specified and stayed fixed for each scene
 - **generate_data_model_random.py** : zones are chosen randomly (just a number of zone is specified)
+- **generate_data_model_random_maxwell.py** : zones are chosen randomly (just a number of zone is specified). Only maxwell scene are used.
 
 
 **Remark** : Note here that all python script have *--help* command.
@@ -53,7 +54,7 @@ python generate_data_model.py --help
 python generate_data_model.py --output xxxx --interval 0,20  --kind svdne --scenes "A, B, D" --zones "0, 1, 2" --percent 0.7 --sep : --rowindex 1
 ```
 
-Parameters explained : 
+Parameters explained :
 - **output** : filename of data (which will be split into two parts, *.train* and *.test* relative to your choices).
 - **interval** : the interval of data you want to use from SVD vector.
 - **kind** : kind of data ['svd', 'svdn', 'svdne']; not normalize, normalize vector only and normalize together.
@@ -113,7 +114,7 @@ Just use --help option to get more information.
 
 All scripts named **predict_seuil_expe\*.py** are used to simulate model prediction during rendering process.
 
-Once you have simulation done. Checkout your **threshold_map/%MODEL_NAME/simulation_curves_zones_\*** folder and use it with help of **display_simulation_curves.py** script.
+Once you have simulation done. Checkout your **threshold_map/%MODEL_NAME%/simulation\_curves\_zones\_\*/** folder and use it with help of **display_simulation_curves.py** script.
 
 ## Others scripts
 
@@ -133,7 +134,7 @@ Parameters list :
 - 5 : Metric used by model
 
 
-### Get treshold map 
+### Get treshold map
 
 Main objective of this project is to predict as well as a human the noise perception on a photo realistic image. Human threshold is available from training data. So a script was developed to give the predicted treshold from model and compare predicted treshold from the expected one.
 
@@ -158,7 +159,7 @@ The content will be divised into two parts :
 The previous script need to already have ran to obtain and display treshold maps on this markdown file.
 
 ```bash
-python save_model_result_in_md.py --interval "xx,xx" --model saved_models/xxxx.joblib --mode ["svd", "svdn", "svdne"] --metric ['lab', 'mscn'] 
+python save_model_result_in_md.py --interval "xx,xx" --model saved_models/xxxx.joblib --mode ["svd", "svdn", "svdne"] --metric ['lab', 'mscn']
 ```
 
 Parameters list :
@@ -174,4 +175,4 @@ All others bash scripts are used to combine and run multiple model combinations.
 
 ## How to contribute
 
-This git project uses [git-flow](https://danielkummer.github.io/git-flow-cheatsheet/) implementation. You are free to contribute to it.git 
+This git project uses [git-flow](https://danielkummer.github.io/git-flow-cheatsheet/) implementation. You are free to contribute to it.git

+ 0 - 60
display_bits_shifted.py

@@ -1,60 +0,0 @@
-from ipfml import image_processing
-from PIL import Image
-import numpy as np
-from ipfml import metrics
-from skimage import color
-
-import cv2
-
-nb_bits = 3
-max_nb_bits = 8
-
-low_bits_svd_values = []
-
-def open_and_display(path, i):
-
-    img = Image.open(path)
-
-    block_used = np.array(img)
-
-    low_bits_block = image_processing.rgb_to_LAB_L_bits(block_used, (i + 1, i + nb_bits + 1))
-
-    low_bits_svd = metrics.get_SVD_s(low_bits_block)
-
-    low_bits_svd = [b / low_bits_svd[0] for b in low_bits_svd]
-
-    low_bits_svd_values[i].append(low_bits_svd)
-
-path_noisy = '/home/jbuisine/Documents/Thesis/Development/NoiseDetection_In_SynthesisImages/fichiersSVD_light/Cuisine01/cuisine01_00050.png'
-path_threshold = '/home/jbuisine/Documents/Thesis/Development/NoiseDetection_In_SynthesisImages/fichiersSVD_light/Cuisine01/cuisine01_00400.png'
-path_ref = '/home/jbuisine/Documents/Thesis/Development/NoiseDetection_In_SynthesisImages/fichiersSVD_light/Cuisine01/cuisine01_01200.png'
-
-path_list = [path_noisy, path_threshold, path_ref]
-
-
-for i in range(0, max_nb_bits - nb_bits + 1):
-
-    low_bits_svd_values.append([])
-    for p in path_list:
-        open_and_display(p, i)
-
-import matplotlib.pyplot as plt
-
-# SVD
-# make a little extra space between the subplots
-
-fig=plt.figure(figsize=(8, 8))
-
-for id, l in enumerate(low_bits_svd_values):
-
-     fig.add_subplot(3, 3, (id + 1))
-     plt.plot(l[0], label='Noisy')
-     plt.plot(l[1], label='Threshold')
-     plt.plot(l[2], label='Reference')
-     plt.title('Low ' + str(nb_bits) + ' bits SVD shifted by ' + str(id))
-     plt.ylabel('Low ' + str(nb_bits) + ' bits SVD values')
-     plt.xlabel('Vector features')
-     plt.legend(bbox_to_anchor=(0.7, 1), loc=2, borderaxespad=0.2)
-     plt.ylim(0, 0.1)
-
-plt.show()

+ 16 - 13
display_bits_shifted_scene.py

@@ -19,26 +19,29 @@ from ipfml import metrics
 from skimage import color
 import matplotlib.pyplot as plt
 
-config_filename   = "config"
-zone_folder       = "zone"
-min_max_filename  = "_min_max_values"
+from modules.utils import config as cfg
 
-# define all scenes values
-scenes_list = ['Appart1opt02', 'Bureau1', 'Cendrier', 'Cuisine01', 'EchecsBas', 'PNDVuePlongeante', 'SdbCentre', 'SdbDroite', 'Selles']
-scenes_indexes = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I']
-choices = ['svd', 'svdn', 'svdne']
-path = '../fichiersSVD_light'
-zones = np.arange(16)
-seuil_expe_filename = 'seuilExpe'
 
-metric_choices = ['lab', 'mscn', 'mscn_revisited', 'low_bits_2', 'low_bits_3', 'low_bits_4']
+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_indexes      = 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
 
 def display_data_scenes(nb_bits, p_scene):
     """
-    @brief Method which generates all .csv files from scenes photos
-    @param path - path of scenes folder information
+    @brief Method display shifted values for specific scene
+    @param nb_bits, number of bits expected
+    @param p_scene, scene we want to show values
     @return nothing
     """
 

+ 17 - 12
display_scenes_zones.py

@@ -19,24 +19,29 @@ from ipfml import metrics
 from skimage import color
 import matplotlib.pyplot as plt
 
-config_filename   = "config"
-zone_folder       = "zone"
-min_max_filename  = "_min_max_values"
+from modules.utils import config as cfg
+
+config_filename     = cfg.config_filename
+zone_folder         = cfg.zone_folder
+min_max_filename    = cfg.min_max_filename_extension
 
 # define all scenes values
-scenes_list = ['Appart1opt02', 'Bureau1', 'Cendrier', 'Cuisine01', 'EchecsBas', 'PNDVuePlongeante', 'SdbCentre', 'SdbDroite', 'Selles']
-scenes_indexes = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I']
-choices = ['svd', 'svdn', 'svdne']
-path = '../fichiersSVD_light'
-zones = np.arange(16)
-seuil_expe_filename = 'seuilExpe'
+scenes_list         = cfg.scenes_names
+scenes_indexes      = 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
 
-metric_choices = ['lab', 'mscn', 'mscn_revisited', 'low_bits_2', 'low_bits_3', 'low_bits_4', 'low_bits_5', 'low_bits_6', 'low_bits_4_shifted_2']
 
 def display_data_scenes(data_type, p_scene, p_kind):
     """
-    @brief Method which generates all .csv files from scenes photos
-    @param path - path of scenes folder information
+    @brief Method which displays data from scene
+    @param data_type,  metric choice
+    @param scene, scene choice
+    @param mode, normalization choice
     @return nothing
     """
 

+ 16 - 10
display_scenes_zones_shifted.py

@@ -19,24 +19,30 @@ from ipfml import metrics
 from skimage import color
 import matplotlib.pyplot as plt
 
-config_filename   = "config"
-zone_folder       = "zone"
-min_max_filename  = "_min_max_values"
+from modules.utils import config as cfg
+
+config_filename     = cfg.config_filename
+zone_folder         = cfg.zone_folder
+min_max_filename    = cfg.min_max_filename_extension
 
 # define all scenes values
-scenes_list = ['Appart1opt02', 'Bureau1', 'Cendrier', 'Cuisine01', 'EchecsBas', 'PNDVuePlongeante', 'SdbCentre', 'SdbDroite', 'Selles']
-scenes_indexes = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I']
-choices = ['svd', 'svdn', 'svdne']
-path = '../fichiersSVD_light'
-zones = np.arange(16)
-seuil_expe_filename = 'seuilExpe'
+scenes_list         = cfg.scenes_names
+scenes_indexes      = 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
 
 def display_data_scenes(p_scene, p_bits, p_shifted):
     """
     @brief Method which generates all .csv files from scenes photos
-    @param path - path of scenes folder information
+    @param p_scene, scene we want to show values
+    @param nb_bits, number of bits expected
+    @param p_shifted, number of bits expected to be shifted
     @return nothing
     """
 

+ 5 - 2
display_simulation_curves.py

@@ -7,10 +7,13 @@ import os, sys, getopt
 from modules.utils.data_type import get_svd_data
 
 label_freq = 6
-folder_path = "Curve_simulations"
-
 
 def display_curves(folder_path):
+    """
+    @brief Method used to display simulation given .csv files
+    @param folder_path, folder which contains all .csv files obtained during simulation
+    @return nothing
+    """
 
     data_files = os.listdir(folder_path)
 

+ 33 - 21
display_svd_zone_scene.py

@@ -22,22 +22,26 @@ from skimage import color
 import matplotlib.pyplot as plt
 from modules.utils.data_type import get_svd_data
 
-config_filename   = "config"
-zone_folder       = "zone"
-min_max_filename  = "_min_max_values"
+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 = ['Appart1opt02', 'Bureau1', 'Cendrier', 'Cuisine01', 'EchecsBas', 'PNDVuePlongeante', 'SdbCentre', 'SdbDroite', 'Selles']
-metric_choices = ['lab', 'mscn', 'mscn_revisited', 'low_bits_2', 'low_bits_3', 'low_bits_4', 'low_bits_5', 'low_bits_6','low_bits_4_shifted_2']
-scenes_indexes = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I']
-choices = ['svd', 'svdn', 'svdne']
-path = './fichiersSVD_light'
-zones = np.arange(16)
-seuil_expe_filename = 'seuilExpe'
+scenes_list         = cfg.scenes_names
+scenes_indexes      = 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
 
-def display_svd_values(p_scene, p_interval, p_zone, p_metric, p_mode):
+def display_svd_values(p_scene, p_interval, p_zone, p_metric, p_mode, p_step):
     """
     @brief Method which gives information about svd curves from zone of picture
     @param p_scene, scene expected to show svd values
@@ -110,13 +114,14 @@ def display_svd_values(p_scene, p_interval, p_zone, p_metric, p_mode):
                     current_counter_index_str = "0" + current_counter_index_str
 
 
-                if current_counter_index >= begin and current_counter_index <= end:
-                    images_indexes.append(current_counter_index_str)
+                if current_counter_index % p_step == 0:
+                    if current_counter_index >= begin and current_counter_index <= end:
+                        images_indexes.append(current_counter_index_str)
 
-                if seuil_learned < int(current_counter_index) and not threshold_image_found:
+                    if seuil_learned < int(current_counter_index) and not threshold_image_found:
 
-                    threshold_image_found = True
-                    threshold_image_zone = current_counter_index_str
+                        threshold_image_found = True
+                        threshold_image_zone = current_counter_index_str
 
                 current_counter_index += step_counter
 
@@ -175,19 +180,23 @@ def display_svd_values(p_scene, p_interval, p_zone, p_metric, p_mode):
 
 def main():
 
+
+    # by default p_step value is 10 to enable all photos
+    p_step = 10
+
     if len(sys.argv) <= 1:
         print('Run with default parameters...')
-        print('python display_svd_zone_scene.py --scene A --interval "0,200" --zone 3 --metric lab --mode svdne')
+        print('python display_svd_zone_scene.py --scene A --interval "0,200" --zone 3 --metric lab --mode svdne --step 50')
         sys.exit(2)
     try:
-        opts, args = getopt.getopt(sys.argv[1:], "hs:i:z:l:m", ["help=", "scene=", "interval=", "zone=", "metric=", "mode="])
+        opts, args = getopt.getopt(sys.argv[1:], "hs:i:z:l:m:s", ["help=", "scene=", "interval=", "zone=", "metric=", "mode=", "step="])
     except getopt.GetoptError:
         # print help information and exit:
-        print('python display_svd_zone_scene.py --scene A --interval "0,200" --zone 3 --metric lab --mode svdne')
+        print('python display_svd_zone_scene.py --scene A --interval "0,200" --zone 3 --metric lab --mode svdne --step 50')
         sys.exit(2)
     for o, a in opts:
         if o == "-h":
-            print('python display_svd_zone_scene.py --scene A --interval "0,200" --zone 3 --metric lab --mode svdne')
+            print('python display_svd_zone_scene.py --scene A --interval "0,200" --zone 3 --metric lab --mode svdne --step 50')
             sys.exit()
         elif o in ("-s", "--scene"):
             p_scene = a
@@ -214,10 +223,13 @@ def main():
             if p_mode not in choices:
                 assert False, "Invalid normalization choice, expected ['svd', 'svdn', 'svdne']"
 
+        elif o in ("-s", "--step"):
+            p_step = int(a)
+
         else:
             assert False, "unhandled option"
 
-    display_svd_values(p_scene, p_interval, p_zone, p_metric, p_mode)
+    display_svd_values(p_scene, p_interval, p_zone, p_metric, p_mode, p_step)
 
 if __name__== "__main__":
     main()

+ 20 - 15
generate_all_data.py

@@ -19,27 +19,32 @@ from ipfml import image_processing
 from ipfml import metrics
 from skimage import color
 
-config_filename   = "config"
-zone_folder       = "zone"
-min_max_filename  = "_min_max_values"
-generic_output_file_svd = '_random.csv'
-output_data_folder = '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 = ['Appart1opt02', 'Bureau1', 'Cendrier', 'Cuisine01', 'EchecsBas', 'PNDVuePlongeante', 'SdbCentre', 'SdbDroite', 'Selles']
-scenes_indexes = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I']
-choices = ['svd', 'svdn', 'svdne']
-path = './fichiersSVD_light'
-zones = np.arange(16)
-seuil_expe_filename = 'seuilExpe'
+scenes_list             = cfg.scenes_names
+scenes_indexes          = cfg.scenes_indices
+choices                 = cfg.normalization_choices
+path                    = cfg.dataset_path
+zones                   = cfg.zones_indices
+seuil_expe_filename     = cfg.seuil_expe_filename
 
-metric_choices = ['lab', 'mscn', 'mscn_revisited', 'low_bits_2', 'low_bits_3', 'low_bits_4', 'low_bits_5', 'low_bits_6','low_bits_4_shifted_2']
-picture_step = 10
+metric_choices          = cfg.metric_choices_labels
+output_data_folder      = cfg.output_data_folder
+
+generic_output_file_svd = '_random.csv'
+picture_step            = 10
 
 def generate_data_svd(data_type, mode):
     """
-    @brief Method which generates all .csv files from scenes photos
-    @param path - path of scenes folder information
+    @brief Method which generates all .csv files from scenes
+    @param data_type,  metric choice
+    @param mode, normalization choice
     @return nothing
     """
 

+ 16 - 11
generate_data_model_random.py

@@ -17,19 +17,24 @@ from PIL import Image
 from ipfml import image_processing
 from ipfml import metrics
 
-config_filename   = "config"
-zone_folder       = "zone"
-min_max_filename  = "_min_max_values"
-generic_output_file_svd = '_random.csv'
-output_data_folder = '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 = ['Appart1opt02', 'Bureau1', 'Cendrier', 'Cuisine01', 'EchecsBas', 'PNDVuePlongeante', 'SdbCentre', 'SdbDroite', 'Selles']
-scenes_indexes = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I']
-choices = ['svd', 'svdn', 'svdne']
-path = './fichiersSVD_light'
-zones = np.arange(16)
-seuil_expe_filename = 'seuilExpe'
+scenes_list             = cfg.scenes_names
+scenes_indexes          = 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
+
+output_data_folder      = cfg.output_data_folder
 
 def construct_new_line(path_seuil, interval, line, sep, index):
     begin, end = interval

+ 17 - 13
generate_data_model_random_maxwell.py

@@ -16,19 +16,23 @@ import json
 from PIL import Image
 from ipfml import image_processing, metrics
 
-config_filename   = "config"
-zone_folder       = "zone"
-min_max_filename  = "_min_max_values"
-generic_output_file_svd = '_random.csv'
-output_data_folder = 'data'
-
-# define all scenes values, here only use Maxwell scenes
-scenes_list = ['Appart1opt02', 'Cuisine01', 'SdbCentre', 'SdbDroite']
-scenes_indexes = ['A', 'D', 'G', 'H']
-choices = ['svd', 'svdn', 'svdne']
-path = './fichiersSVD_light'
-zones = np.arange(16)
-seuil_expe_filename = 'seuilExpe'
+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.maxwell_scenes_names
+scenes_indexes          = cfg.maxwell_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
+output_data_folder      = cfg.output_data_folder
 
 min_value_interval = sys.maxsize
 max_value_interval = 0

+ 27 - 0
modules/utils/config.py

@@ -0,0 +1,27 @@
+import numpy as np
+
+config_filename                 = "config"
+zone_folder                     = "zone"
+min_max_filename_extension      = "_min_max_values"
+output_data_folder              = 'data'
+dataset_path                    = 'fichiersSVD_light'
+seuil_expe_filename             = 'seuilExpe'
+threshold_map_folder            = 'threshold_map'
+models_information_folder       = 'models_info'
+saved_models_folder             = 'saved_models'
+csv_model_comparisons_filename  = "models_comparisons.csv"
+
+models_names_list               = ["svm_model","ensemble_model","ensemble_model_v2"]
+
+
+# define all scenes values
+scenes_names                    = ['Appart1opt02', 'Bureau1', 'Cendrier', 'Cuisine01', 'EchecsBas', 'PNDVuePlongeante', 'SdbCentre', 'SdbDroite', 'Selles']
+scenes_indices                  = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I']
+
+maxwell_scenes_names            = ['Appart1opt02', 'Cuisine01', 'SdbCentre', 'SdbDroite']
+maxwell_scenes_indices          = ['A', 'D', 'G', 'H']
+
+normalization_choices           = ['svd', 'svdn', 'svdne']
+zones_indices                   = np.arange(16)
+
+metric_choices_labels           = ['lab', 'mscn', 'mscn_revisited', 'low_bits_2', 'low_bits_3', 'low_bits_4', 'low_bits_5', 'low_bits_6','low_bits_4_shifted_2']

+ 23 - 20
predict_seuil_expe.py

@@ -9,18 +9,21 @@ import sys, os, getopt
 import subprocess
 import time
 
-current_dirpath = os.getcwd()
+from modules.utils import config as cfg
+
+config_filename           = cfg.config_filename
+scenes_path               = cfg.dataset_path
+min_max_filename          = cfg.min_max_filename_extension
+threshold_expe_filename   = cfg.seuil_expe_filename
 
-config_filename   = "config"
-scenes_path = './fichiersSVD_light'
-min_max_filename = '_min_max_values'
-threshold_expe_filename = 'seuilExpe'
-tmp_filename = '/tmp/__model__img_to_predict.png'
+threshold_map_folder      = cfg.threshold_map_folder
+threshold_map_file_prefix = cfg.threshold_map_folder + "_"
 
-threshold_map_folder = "threshold_map"
-threshold_map_file_prefix = "treshold_map_"
+zones                     = cfg.zones_indices
 
-zones = np.arange(16)
+tmp_filename              = '/tmp/__model__img_to_predict.png'
+
+current_dirpath = os.getcwd()
 
 def main():
 
@@ -47,7 +50,7 @@ def main():
 
             if p_mode != 'svdn' and p_mode != 'svdne' and p_mode != 'svd':
                 assert False, "Mode not recognized"
-    
+
         elif o in ("-me", "--metric"):
             p_metric = a
         elif o in ("-l", "--limit_detection"):
@@ -56,13 +59,13 @@ def main():
             assert False, "unhandled option"
 
     scenes = os.listdir(scenes_path)
-    
+
     if min_max_filename in scenes:
         scenes.remove(min_max_filename)
 
     # go ahead each scenes
     for id_scene, folder_scene in enumerate(scenes):
-    
+
         print(folder_scene)
 
         scene_path = os.path.join(scenes_path, folder_scene)
@@ -106,7 +109,7 @@ def main():
         check_all_done = False
 
         while(current_counter_index <= end_counter_index and not check_all_done):
-            
+
             current_counter_index_str = str(current_counter_index)
 
             while len(start_index_image) > len(current_counter_index_str):
@@ -121,7 +124,7 @@ def main():
             check_all_done = all(d == True for d in threshold_expes_detected)
 
             for id_block, block in enumerate(img_blocks):
-                
+
                 # check only if necessary for this scene (not already detected)
                 if not threshold_expes_detected[id_block]:
 
@@ -135,9 +138,9 @@ def main():
 
                     ## call command ##
                     p = subprocess.Popen(python_cmd, stdout=subprocess.PIPE, shell=True)
-                    
+
                     (output, err) = p.communicate()
-                    
+
                     ## Wait for result ##
                     p_status = p.wait()
 
@@ -147,7 +150,7 @@ def main():
                         threshold_expes_counter[id_block] = threshold_expes_counter[id_block] + 1
                     else:
                         threshold_expes_counter[id_block] = 0
-                    
+
                     if threshold_expes_counter[id_block] == p_limit:
                         threshold_expes_detected[id_block] = True
                         threshold_expes_found[id_block] = current_counter_index
@@ -163,7 +166,7 @@ def main():
 
         # construct path using model name for saving threshold map folder
         model_treshold_path = os.path.join(threshold_map_folder, p_model_file.split('/')[-1].replace('.joblib', ''))
-        
+
         # create threshold model path if necessary
         if not os.path.exists(model_treshold_path):
             os.makedirs(model_treshold_path)
@@ -186,7 +189,7 @@ def main():
             if (id + 1) % 4 == 0:
                 f_map.write(line_information + '\n')
                 line_information = ""
-        
+
         f_map.write(line_information + '\n')
 
         min_abs_dist = min(abs_dist)
@@ -215,4 +218,4 @@ def main():
 
 
 if __name__== "__main__":
-    main()
+    main()

+ 14 - 10
predict_seuil_expe_maxwell.py

@@ -9,20 +9,24 @@ import sys, os, getopt
 import subprocess
 import time
 
-current_dirpath = os.getcwd()
 
-config_filename   = "config"
-scenes_path = './fichiersSVD_light'
-min_max_filename = '_min_max_values'
-threshold_expe_filename = 'seuilExpe'
-tmp_filename = '/tmp/__model__img_to_predict.png'
+from modules.utils import config as cfg
+
+config_filename           = cfg.config_filename
+scenes_path               = cfg.dataset_path
+min_max_filename          = cfg.min_max_filename_extension
+threshold_expe_filename   = cfg.seuil_expe_filename
+
+threshold_map_folder      = cfg.threshold_map_folder
+threshold_map_file_prefix = cfg.threshold_map_folder + "_"
 
-maxwell_scenes = ['Appart1opt02', 'Cuisine01', 'SdbCentre', 'SdbDroite']
+zones                     = cfg.zones_indices
+maxwell_scenes            = cfg.maxwell_scenes_names
 
-threshold_map_folder = "threshold_map"
-threshold_map_file_prefix = "treshold_map_"
+tmp_filename              = '/tmp/__model__img_to_predict.png'
+
+current_dirpath = os.getcwd()
 
-zones = np.arange(16)
 
 def main():
 

+ 14 - 10
predict_seuil_expe_maxwell_curve.py

@@ -9,20 +9,24 @@ import sys, os, getopt
 import subprocess
 import time
 
-current_dirpath = os.getcwd()
+from modules.utils import config as cfg
+
+config_filename           = cfg.config_filename
+scenes_path               = cfg.dataset_path
+min_max_filename          = cfg.min_max_filename_extension
+threshold_expe_filename   = cfg.seuil_expe_filename
 
-config_filename   = "config"
-scenes_path = './fichiersSVD_light'
-min_max_filename = '_min_max_values'
-threshold_expe_filename = 'seuilExpe'
-tmp_filename = '/tmp/__model__img_to_predict.png'
+threshold_map_folder      = cfg.threshold_map_folder
+threshold_map_file_prefix = cfg.threshold_map_folder + "_"
 
-maxwell_scenes = ['Appart1opt02', 'Cuisine01', 'SdbCentre', 'SdbDroite']
+zones                     = cfg.zones_indices
+maxwell_scenes            = cfg.maxwell_scenes_names
 
-threshold_map_folder = "threshold_map"
-simulation_curves_zones = "simulation_curves_zones_"
+simulation_curves_zones   = "simulation_curves_zones_"
+tmp_filename              = '/tmp/__model__img_to_predict.png'
+
+current_dirpath = os.getcwd()
 
-zones = np.arange(16)
 
 def main():
 

+ 6 - 4
prediction_scene.py

@@ -7,7 +7,9 @@ from sklearn.metrics import accuracy_score
 
 import sys, os, getopt
 
-output_model_folder = './saved_models/'
+from modules.utils import config as cfg
+
+output_model_folder = cfg.saved_models_folder
 
 def main():
 
@@ -53,7 +55,7 @@ def main():
     y_not_noisy_dataset = not_noisy_dataset.ix[:, 0]
     x_not_noisy_dataset = not_noisy_dataset.ix[:, 1:]
 
-    model = joblib.load(p_model_file) 
+    model = joblib.load(p_model_file)
 
     y_pred = model.predict(x_dataset)
     y_noisy_pred = model.predict(x_noisy_dataset)
@@ -66,7 +68,7 @@ def main():
     if(p_scene):
         print(p_scene + " | " + str(accuracy_global) + " | " + str(accuracy_noisy) + " | " + str(accuracy_not_noisy))
     else:
-        print(str(accuracy_global) + " \t | " + str(accuracy_noisy) + " \t | " + str(accuracy_not_noisy)) 
+        print(str(accuracy_global) + " \t | " + str(accuracy_noisy) + " \t | " + str(accuracy_not_noisy))
 
         with open(p_output, 'w') as f:
             f.write("Global accuracy found %s " % str(accuracy_global))
@@ -77,4 +79,4 @@ def main():
 
 
 if __name__== "__main__":
-    main()
+    main()

+ 15 - 13
save_model_result_in_md.py

@@ -9,14 +9,16 @@ import sys, os, getopt
 import subprocess
 import time
 
-current_dirpath = os.getcwd()
 
-threshold_map_folder = "threshold_map"
-threshold_map_file_prefix = "treshold_map_"
+from modules.utils import config as cfg
+
+threshold_map_folder      = cfg.threshold_map_folder
+threshold_map_file_prefix = cfg.threshold_map_folder + "_"
 
-markdowns_folder = "models_info"
+markdowns_folder          = cfg.models_information_folder
+zones                     = cfg.zones_indices
 
-zones = np.arange(16)
+current_dirpath = os.getcwd()
 
 def main():
 
@@ -48,25 +50,25 @@ def main():
         else:
             assert False, "unhandled option"
 
-    
+
     # call model and get global result in scenes
 
     begin, end = p_interval
 
-    bash_cmd = "bash testModelByScene.sh '" + str(begin) + "' '" + str(end) + "' '" + p_model_file + "' '" + p_mode + "' '" + p_metric + "'" 
+    bash_cmd = "bash testModelByScene.sh '" + str(begin) + "' '" + str(end) + "' '" + p_model_file + "' '" + p_mode + "' '" + p_metric + "'"
     print(bash_cmd)
-     
+
     ## call command ##
     p = subprocess.Popen(bash_cmd, stdout=subprocess.PIPE, shell=True)
-    
+
     (output, err) = p.communicate()
-    
+
     ## Wait for result ##
     p_status = p.wait()
 
     if not os.path.exists(markdowns_folder):
         os.makedirs(markdowns_folder)
-        
+
     # get model name to construct model
     md_model_path = os.path.join(markdowns_folder, p_model_file.split('/')[-1].replace('.joblib', '.md'))
 
@@ -83,7 +85,7 @@ def main():
 
             # get all map information
             for t_map_file in maps_files:
-                
+
                 file_path = os.path.join(model_map_info_path, t_map_file)
                 with open(file_path, 'r') as map_file:
 
@@ -98,4 +100,4 @@ def main():
         f.close()
 
 if __name__== "__main__":
-    main()
+    main()

+ 10 - 7
save_model_result_in_md_maxwell.py

@@ -14,16 +14,19 @@ import sys, os, getopt
 import subprocess
 import time
 
-current_dirpath = os.getcwd()
+from modules.utils import config as cfg
+
+threshold_map_folder        = cfg.threshold_map_folder
+threshold_map_file_prefix   = cfg.threshold_map_folder + "_"
 
-threshold_map_folder = "threshold_map"
-threshold_map_file_prefix = "treshold_map_"
+markdowns_folder            = cfg.models_information_folder
+final_csv_model_comparisons = cfg.csv_model_comparisons_filename
+models_name                 = cfg.models_names_list
 
-markdowns_folder = "models_info"
-final_csv_model_comparisons = "models_comparisons.csv"
-models_name = ["svm_model","ensemble_model","ensemble_model_v2"]
+zones                       = cfg.zones_indices
+
+current_dirpath = os.getcwd()
 
-zones = np.arange(16)
 
 def main():