Browse Source

Study of Julia; Correction of simulation script

Jérôme BUISINE 1 year ago
parent
commit
a1b9cd78b1

File diff suppressed because it is too large
+ 355 - 0
analysis/.ipynb


File diff suppressed because it is too large
+ 253 - 0
analysis/gradient_matrix_synthesis_images.ipynb


File diff suppressed because it is too large
+ 331 - 0
analysis/julia_ml.ipynb


+ 185 - 0
analysis/mscn_and_lab_analysis.ipynb

@@ -0,0 +1,185 @@
+{
+ "cells": [
+  {
+   "cell_type": "code",
+   "execution_count": 18,
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "from ipfml import processing, utils, metrics\n",
+    "from PIL import Image\n",
+    "from scipy import signal\n",
+    "from skimage import color\n",
+    "import scipy.stats as stats\n",
+    "import seaborn as sns\n",
+    "import cv2\n",
+    "import numpy as np\n",
+    "import matplotlib.pyplot as plt\n",
+    "import os"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 4,
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "data_folder = \"../fichiersSVD_light\""
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "# MSCN analysis on Synthesis Images "
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "## Utils functions definition"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 5,
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "def compute_images_path(scene, prefix, indices):\n",
+    "    images_path = []\n",
+    "    for index in indices:\n",
+    "        path = os.path.join(data_folder, os.path.join(scene, prefix + index + \".png\"))\n",
+    "        print(path)\n",
+    "        images_path.append(path)\n",
+    "    return images_path"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 40,
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "def get_L_canal(img):\n",
+    "    img_lab = metrics.get_LAB_L(img)\n",
+    "    img_lab = np.asarray(img_lab, 'uint8')\n",
+    "    \n",
+    "    return Image.fromarray(img_lab)"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 38,
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "def get_MSCN_canal(img):\n",
+    "    img_mscn = processing.get_mscn_coefficients(img)\n",
+    "    img_mscn = np.asarray(utils.normalize_2D_arr(img_mscn)*255, 'uint8')\n",
+    "    \n",
+    "    return Image.fromarray(img_mscn)"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "## Scenes MSCN variance analysis"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "### Cuisine01 scene "
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 31,
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "scene_name = \"Cuisine01\"\n",
+    "prefix_name = \"cuisine01_\"\n",
+    "image_indices = [\"00050\", \"00100\", \"00200\", \"00300\", \"00500\", \"00900\",\"01200\"]"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 37,
+   "metadata": {},
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "../fichiersSVD_light/Cuisine01/cuisine01_00050.png\n",
+      "../fichiersSVD_light/Cuisine01/cuisine01_00100.png\n",
+      "../fichiersSVD_light/Cuisine01/cuisine01_00200.png\n",
+      "../fichiersSVD_light/Cuisine01/cuisine01_00300.png\n",
+      "../fichiersSVD_light/Cuisine01/cuisine01_00500.png\n",
+      "../fichiersSVD_light/Cuisine01/cuisine01_00900.png\n",
+      "../fichiersSVD_light/Cuisine01/cuisine01_01200.png\n"
+     ]
+    }
+   ],
+   "source": [
+    "images_path = compute_images_path(scene_name, prefix_name, image_indices)"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 46,
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "get_L_canal(processing.divide_in_blocks(Image.open(images_path[0]), (200, 200))[10]).save('tmp_images/cuisine01_zone10_00050_lab.png')\n",
+    "get_L_canal(processing.divide_in_blocks(Image.open(images_path[5]), (200, 200))[10]).save('tmp_images/cuisine01_zone10_01200_lab.png')"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 47,
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "get_MSCN_canal(processing.divide_in_blocks(Image.open(images_path[0]), (200, 200))[10]).save('tmp_images/cuisine01_zone10_00050_mscn.png')\n",
+    "get_MSCN_canal(processing.divide_in_blocks(Image.open(images_path[5]), (200, 200))[10]).save('tmp_images/cuisine01_zone10_01200_mscn.png')"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 49,
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "processing.divide_in_blocks(Image.open(images_path[0]), (200, 200))[10].save('tmp_images/cuisine01_zone10_noisy.png')\n",
+    "processing.divide_in_blocks(Image.open(images_path[5]), (200, 200))[10].save('tmp_images/cuisine01_zone10_ref.png')"
+   ]
+  }
+ ],
+ "metadata": {
+  "kernelspec": {
+   "display_name": "thesis-venv",
+   "language": "python",
+   "name": "thesis-venv"
+  },
+  "language_info": {
+   "codemirror_mode": {
+    "name": "ipython",
+    "version": 3
+   },
+   "file_extension": ".py",
+   "mimetype": "text/x-python",
+   "name": "python",
+   "nbconvert_exporter": "python",
+   "pygments_lexer": "ipython3",
+   "version": "3.6.0"
+  }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 2
+}

File diff suppressed because it is too large
+ 274 - 0
analysis/noise_mask_svd.ipynb


+ 1 - 1
analysis/svd_ica_scenes_analysis.ipynb

@@ -280,7 +280,7 @@
    "cell_type": "markdown",
    "metadata": {},
    "source": [
-    "Essayer de garder uniquement les composante faibles et comparer avec ICA"
+    "Essayer de garder uniquement les composantes faibles et comparer avec ICA"
    ]
   },
   {

+ 10 - 29
analysis/svd_ipca_scenes_analysis.ipynb

@@ -2,7 +2,7 @@
  "cells": [
   {
    "cell_type": "code",
-   "execution_count": 3,
+   "execution_count": 2,
    "metadata": {},
    "outputs": [],
    "source": [
@@ -26,7 +26,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 4,
+   "execution_count": 3,
    "metadata": {},
    "outputs": [],
    "source": [
@@ -49,7 +49,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 5,
+   "execution_count": 4,
    "metadata": {},
    "outputs": [],
    "source": [
@@ -73,7 +73,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 6,
+   "execution_count": 5,
    "metadata": {},
    "outputs": [],
    "source": [
@@ -121,7 +121,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 7,
+   "execution_count": 6,
    "metadata": {},
    "outputs": [],
    "source": [
@@ -148,7 +148,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 8,
+   "execution_count": 7,
    "metadata": {},
    "outputs": [],
    "source": [
@@ -158,7 +158,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 9,
+   "execution_count": 8,
    "metadata": {},
    "outputs": [
     {
@@ -206,28 +206,9 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 13,
+   "execution_count": 11,
    "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "../fichiersSVD_light/Appart1opt02/appartAopt_00020.png\n",
-      "../fichiersSVD_light/Appart1opt02/appartAopt_00200.png\n",
-      "../fichiersSVD_light/Appart1opt02/appartAopt_00900.png\n",
-      "../fichiersSVD_light/Cuisine01/cuisine01_00050.png\n",
-      "../fichiersSVD_light/Cuisine01/cuisine01_00400.png\n",
-      "../fichiersSVD_light/Cuisine01/cuisine01_01200.png\n",
-      "../fichiersSVD_light/SdbCentre/SdB2_00020.png\n",
-      "../fichiersSVD_light/SdbCentre/SdB2_00400.png\n",
-      "../fichiersSVD_light/SdbCentre/SdB2_00950.png\n",
-      "../fichiersSVD_light/SdbDroite/SdB2_D_00020.png\n",
-      "../fichiersSVD_light/SdbDroite/SdB2_D_00400.png\n",
-      "../fichiersSVD_light/SdbDroite/SdB2_D_00950.png\n"
-     ]
-    }
-   ],
+   "outputs": [],
    "source": [
     "all_trunc_svd_sv = []\n",
     "\n",
@@ -255,7 +236,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 14,
+   "execution_count": 10,
    "metadata": {},
    "outputs": [
     {

File diff suppressed because it is too large
+ 44 - 28
analysis/svd_reconstruction_analysis.ipynb


+ 0 - 1
generate_data_model_random.py

@@ -44,7 +44,6 @@ generic_output_file_svd = '_random.csv'
 min_value_interval      = sys.maxsize
 max_value_interval      = 0
 
-
 def construct_new_line(path_seuil, interval, line, choice, each, norm):
     begin, end = interval
 

+ 36 - 0
julia_train_model.jl

@@ -0,0 +1,36 @@
+using DataFrames
+using CSV
+using PyCall, JLD, PyCallJLD
+using ArgParse
+
+
+function main(args)
+
+    # initialize the settings (the description is for the help screen)
+    s = ArgParseSettings(description = "Example 1 for argparse.jl: minimal usage.")
+
+    @add_arg_table s begin
+        "--data"    
+        #    arg_type = Int           # only Int arguments allowed
+        #    nargs = '?'              # '?' means optional argument
+        #    default = 0              # this is used when the option is not passed
+        #    constant = 1             # this is used if --opt1 is paseed with no argument
+            help = "Data file for train and test"
+        
+        "--output"
+            help = "output model name"
+
+        "choice"
+            help = "Model choice"
+    end
+
+    parsed_args = parse_args(s) # the result is a Dict{String,Any}
+
+    println(parsed_args["data"])
+    println("Parsed args:")
+    for (key,val) in parsed_args
+        println("  $key  =>  $(repr(val))")
+    end
+end
+
+main(ARGS)

+ 1 - 1
run_maxwell_simulation_custom.sh

@@ -8,7 +8,7 @@ scenes="A, D, G, H"
 VECTOR_SIZE=200
 
 for size in {"4","8","16","26","32","40"}; do
-    for metric in {"lab","mscn","mscn_revisited","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","mscn_revisited","low_bits_2","low_bits_3","low_bits_4","low_bits_5","low_bits_6","low_bits_4_shifted_2","ica_diff","ipca_diff","svd_trunc_diff","svd_reconstruct"}; do
 
         half=$(($size/2))
         start=-$half