Parcourir la source

Scripts updates

Jérôme BUISINE il y a 5 ans
Parent
commit
787d73d8f8
7 fichiers modifiés avec 19 ajouts et 63 suppressions
  1. 2 0
      .gitignore
  2. 3 0
      make_dataset.py
  3. 0 56
      models_info/models_comparisons.csv
  4. 3 1
      modules/config.py
  5. 7 2
      reconstruct.py
  6. 1 1
      reconstruct_scene_mean.py
  7. 3 3
      run.sh

+ 2 - 0
.gitignore

@@ -5,4 +5,6 @@ data
 saved_models
 reconstructed
 
+models_info/models_comparisons.csv
+
 __pycache__

+ 3 - 0
make_dataset.py

@@ -27,6 +27,9 @@ def compute_files(_n, _each_row, _each_column):
     scenes = [s for s in scenes if s not in cfg.folder_and_files_filtered]
     scenes = [s for s in scenes if '.csv' not in s] # do not keep generated .csv file
 
+    # skip test scene from dataset
+    scenes = [ s for s in scenes if s not in cfg.test_scenes]
+
     # print(scenes)
 
     counter = 0

+ 0 - 56
models_info/models_comparisons.csv

@@ -1,56 +0,0 @@
-model_name; number_of_approximations; coeff_of_determination;
-10_column_7_row_7_SGD;60236;0.9664839093717277;
-10_column_8_row_7_SGD;52096;0.9678826169810406;
-10_column_9_row_7_SGD;46398;0.9675521117545538;
-10_column_10_row_7_SGD;42328;0.9690566006746083;
-10_column_7_row_8_SGD;52096;0.9670321876554149;
-10_column_8_row_8_SGD;45056;0.9675700963072098;
-10_column_9_row_8_SGD;40128;0.9681146909422683;
-10_column_10_row_8_SGD;36608;0.9685975892512967;
-10_column_7_row_9_SGD;46398;0.9659828384202058;
-10_column_8_row_9_SGD;40128;0.9643140500095528;
-10_column_9_row_9_SGD;35739;0.9681206252300265;
-10_column_10_row_9_SGD;32604;0.9675376275385571;
-10_column_7_row_10_SGD;42328;0.9668247142099193;
-10_column_8_row_10_SGD;36608;0.9691928437989377;
-10_column_9_row_10_SGD;32604;0.9664142765421678;
-10_column_10_row_10_SGD;29744;0.96557812475763;
-10_column_7_row_7_Ridge;60236;0.9692904801421809;
-10_column_8_row_7_Ridge;52096;0.9688142127098829;
-10_column_9_row_7_Ridge;46398;0.9690793257605756;
-10_column_10_row_7_Ridge;42328;0.9692175480850063;
-10_column_7_row_8_Ridge;52096;0.9698205957605032;
-10_column_8_row_8_Ridge;45056;0.9687118568270947;
-10_column_9_row_8_Ridge;40128;0.9684702429653922;
-10_column_10_row_8_Ridge;36608;0.9689162994646794;
-10_column_7_row_9_Ridge;46398;0.9681677305109241;
-10_column_8_row_9_Ridge;40128;0.9660094332410658;
-10_column_9_row_9_Ridge;35739;0.9682634948079946;
-10_column_10_row_9_Ridge;32604;0.9676850705782724;
-10_column_7_row_10_Ridge;42328;0.9695503288973929;
-10_column_8_row_10_Ridge;36608;0.9692597134505115;
-10_column_9_row_10_Ridge;32604;0.9687488258562307;
-10_column_10_row_10_Ridge;29744;0.9680152308298698;
-10_column_7_row_7_SVR;60236;0.5717571135650313;
-10_column_8_row_7_SVR;52096;0.6064102246558929;
-10_column_9_row_7_SVR;46398;0.5641867800046533;
-10_column_10_row_7_SVR;42328;0.6150038267137997;
-10_column_7_row_8_SVR;52096;0.6206357673873072;
-10_column_8_row_8_SVR;45056;0.6331979961058917;
-10_column_9_row_8_SVR;40128;0.6217743796094698;
-10_column_10_row_8_SVR;36608;0.5907704117075545;
-10_column_7_row_9_SVR;46398;0.5735147080322717;
-10_column_8_row_9_SVR;40128;0.5360869924085242;
-10_column_9_row_9_SVR;35739;0.5669606458527935;
-10_column_10_row_9_SVR;32604;0.6161197699110612;
-10_column_7_row_10_SVR;42328;0.5742907589869939;
-10_column_8_row_10_SVR;36608;0.5830646274016172;
-10_column_9_row_10_SVR;32604;0.5595641043122157;
-10_column_10_row_10_SVR;29744;0.5683530544960993;
-15_column_7_row_7_SGD;60236;0.9771975053790135;
-15_column_8_row_7_SGD;52096;0.9774661245238926;
-15_column_9_row_7_SGD;46398;0.9798232669284889;
-15_column_10_row_7_SGD;42328;0.9780344702252113;
-15_column_7_row_8_SGD;52096;0.9783939220775737;
-15_column_8_row_8_SGD;45056;0.9763709016819202;
-15_column_9_row_8_SGD;40128;0.9792719020865562;

+ 3 - 1
modules/config.py

@@ -13,4 +13,6 @@ number_of_columns               = 512
 kind_of_models                  = ["SGD", "Ridge", "SVR"]
 
 global_result_filepath          = "models_info/models_comparisons.csv"
-scenes_list                     = ['Exterieur01', 'Boulanger', 'CornellBoxNonVideTextureArcade', 'CornellBoxVide', 'Bar1', 'CornellBoxNonVideTextureDegrade', 'CornellBoxNonVideTextureDamier', 'CornellBoxVideTextureDamier', 'CornellBoxNonVide', 'Sponza1', 'Bureau1_cam2']
+scenes_list                     = ['Exterieur01', 'Boulanger', 'CornellBoxNonVideTextureArcade', 'CornellBoxVide', 'Bar1', 'CornellBoxNonVideTextureDegrade', 'CornellBoxNonVideTextureDamier', 'CornellBoxVideTextureDamier', 'CornellBoxNonVide', 'Sponza1', 'Bureau1_cam2']
+
+test_scenes                     = []

+ 7 - 2
reconstruct.py

@@ -30,7 +30,7 @@ def reconstruct(_scene_name, _model_path, _n):
         folder_path = os.path.join(scene_path, str(id_column))
 
         pixels = []
-        
+
         for id_row in range(cfg.number_of_rows):
             
             pixel_filename = _scene_name + '_' + str(id_column) + '_' + str(id_row) + ".dat"
@@ -45,7 +45,12 @@ def reconstruct(_scene_name, _model_path, _n):
 
         # predict column pixels and fill image column by column
         pixels_predicted = clf.predict(pixels)
-        output_image[id_column] = pixels_predicted*255.
+
+        # change normalized predicted value to pixel value
+        pixels_predicted = pixels_predicted*255.
+
+        for id_pixel, pixel in enumerate(pixels_predicted):
+            output_image[id_pixel, id_column] = pixel
 
         print("{0:.2f}%".format(id_column / cfg.number_of_columns * 100))
         sys.stdout.write("\033[F")

+ 1 - 1
reconstruct_scene_mean.py

@@ -36,7 +36,7 @@ def reconstruct(_scene_name):
                 # predict the expected pixel value
                 lines = [float(l) for l in f.readlines()]
                 mean = sum(lines) / float(len(lines))
-                
+
             output_image[id_row, id_column] = mean
 
         print("{0:.2f}%".format(id_column / cfg.number_of_columns * 100))

+ 3 - 3
run.sh

@@ -13,10 +13,10 @@ if [ "${erased}" == "Y" ]; then
     echo 'model_name; number_of_approximations; coeff_of_determination;' >> ${file_path}
 fi
 
-for n in {10,15,20,25,30}; do
+for n in {3,4,5,6,7,8,9,10,15,20,25,30}; do
     for model in {"SGD","Ridge","SVR"}; do
-        for row in {7,8,9,10}; do
-            for column in {7,8,9,10}; do
+        for row in {2,3,4,5,6,7,8,9,10}; do
+            for column in {2,3,4,5,6,7,8,9,10}; do
 
                 # Run creation of dataset and train model
                 DATASET_NAME="data/dataset_${n}_column_${column}_row_${row}.csv"