Commit a822d8d4 authored by Mano Brabant's avatar Mano Brabant
Browse files

Update README.md

parent 8f519968
...@@ -6,12 +6,22 @@ This project aims at automatically denoising phase images using a CNN residual f ...@@ -6,12 +6,22 @@ This project aims at automatically denoising phase images using a CNN residual f
## Prerequisites TODO ## Prerequisites TODO
This project needs the following python3 packages This project needs the following python3 packages
``` ```
pip3 install arparse pathlib os sys PIL numpy scipy conda install -c pytorch pytorch
conda install pillow
conda install scipy
conda install matplotlib
conda install -c pytorch torchvision
``` ```
Python == 3.9
PyTorch == 1.7.1 PyTorch == 1.7.1
## Parameters ## Parameters
Modifiable parameters are located in argument.py Modifiable parameters are located in argument.py
Use the following command to see thee different parameters you can use.
```
python3 main_holo.py --help
```
## Localization of data and generation of patches ## Localization of data and generation of patches
...@@ -30,30 +40,31 @@ All phase data is converted using sine or cosine functions and normalized betwee ...@@ -30,30 +40,31 @@ All phase data is converted using sine or cosine functions and normalized betwee
Patch size can be given as an argument in the command line either if images .tiff are all in the same directory, or if the .mat files are given in seperated directories. Patch size can be given as an argument in the command line either if images .tiff are all in the same directory, or if the .mat files are given in seperated directories.
``` ```
python3 generate_patches_holo.py --patch_size 100 python3 generate_patches_holo.py --patch_size 100
python3 generate_patches_holo_fromMat.py --patch_size 100 python3 generate_patches_holo_fromMat.py
``` ```
This command generates two numpy matrices of size (nb_patch, patch_size, patch_size,1) one for noisy images, the other for clean references. This command generates two numpy matrices of size (args.batch_size * nb_image, patch_size, patch_size, 1) one for noisy images, the other for clean references.
## Manual ## Manual
You have to manualy download the holography database and put it in the directory. In order to train models you have to manualy download an holography database and give the path to that directory for training database (args.train_dir) evaluating database (args.eval_dir) and testing database (args.test_dir).
The database can be found on skinner /info/etu/m1/s171085/Projets/Portage-Keras-PyTorch/Portage-reseau-de-neurones-de-Keras-vers-PyTorch/dncnn-tensorflow-holography-master/Holography (a new link will be available later)
The application can be used with the main_holo.py script with different arguments from the argument.py script A database can be found on skinner /info/etu/m1/s171085/Projets/Portage-Keras-PyTorch/Portage-reseau-de-neurones-de-Keras-vers-PyTorch/dncnn-tensorflow-holography-master/Holography or here https://lium-cloud.univ-lemans.fr/index.php/s/8gLGetFsFcGQgMo
To start a training with default param you can use the command
The application is used with the main_holo.py script with different arguments from the argument.py script.
To start a training with default parameters you can use the command.
``` ```
#launch a training #launch a training
python3 main_holo.py python3 main_holo.py
``` ```
You can precise the training and eval data with the arguments noisy_train, clean_train, noisy_eval and clean_eval You can precise the training data with the arguments noisy_train, clean_train. Ans the eval data with the arguments eval_patterns and eval_noises.
The usable data are generated with the generate_patches_holo.py and generate_patches_holo_fromMAT.py scripts and saved in a directory named "data1". The data are generated with the generate_patches_holo.py and generate_patches_holo_fromMAT.py scripts and saved in a directory named "data1".
``` ```
#launch a training with the following data #launch a training with the following data
python3 main_holo.py --noisy_train data1/img_noisy_train_1-2-3-4-5_0-1-1.5-2-2.5_two_50_50_384.npy --clean_train data1/img_clean_train_1-2-3-4-5_0-1-1.5-2-2.5_two_50_50_384.npy --noisy_eval data1/img_noisy_train_1-2-3-4-5_0-1-1.5-2-2.5_two_50_50_384.npy --clean_eval data1/img_clean_train_1-2-3-4-5_0-1-1.5-2-2.5_two_50_50_384.npy python3 main_holo.py --noisy_train data1/img_noisy_train_1-2-3-4-5_0-1-1.5-2-2.5_two_50_50_384.npy --clean_train data1/img_clean_train_1-2-3-4-5_0-1-1.5-2-2.5_two_50_50_384.npy --eval_patterns 1 2 3 --eval_noises "0-1-1.5"
``` ```
You can also precise the different hyperparameter for the training You can also precise the different hyperparameters for the training
num_epoch is the number of epoch the model will train num_epoch is the number of epoch the model will train
D is the number of res block D is the number of res block
C is the kernel size for convolutional layer (not tested) C is the kernel size for convolutional layer (not tested)
...@@ -62,28 +73,32 @@ C is the kernel size for convolutional layer (not tested) ...@@ -62,28 +73,32 @@ C is the kernel size for convolutional layer (not tested)
python3 main_holo.py --num_epoch 500 --D 16 --C 32 python3 main_holo.py --num_epoch 500 --D 16 --C 32
``` ```
For data adapation you have to give the size and the number of channel of the image you will be using in the argument image_size and image_mode (for training or testing). For data adapation you have to give the size and the number of channel of the image you will be using in the argument (train|eval|test)_image_size and image_mode.
``` ```
#launch a training in which the image will be 50 by 50 in black and white #launch a training in which the image will be 50 by 50 in black and white
python3 main_holo.py --image_size 50 50 --image_mode 1 python3 main_holo.py --train_image_size 50 50 --image_mode 1
``` ```
The arguments input_dir and epoch are used for re-training and de-noising operation. The arguments input_dir and epoch are used for re-training and de-noising operation.
In input_dir give the path to the model you want to use, and in epoch give the number from which you want to re-train or do a de-noising operation. In input_dir give the path to the model you want to use, and in epoch give the number from which you want to re-train or do a de-noising operation.
The model are saved in a directory named "PyTorchExperiments" The new model will be saved in the input_dir directory.
``` ```
#re launch a training strating from the model experiment_xxx at the epoch 130 #re launch a training strating from the model experiment_xxx at the epoch 130
python3 main_holo.py --input_dir PyTorchExperiments/experiment_xxx --epoch 130 python3 main_holo.py --input_dir PyTorchExperiments/experiment_xxx --epoch 130
``` ```
To do a de-noising operation you can use the test_mode argument. To do a de-noising operation you have to use the test_mode argument.
You can use the argument test_noisy_img, test_noisy_key, test_clean_img and test_clean_key to precise which image you want to de-noise You can use the argument test_noisy_img, test_noisy_key, test_clean_img and test_clean_key to precise which image you want to de-noise
The clean image will only be used to give the level of remaining noise after the de-noising operation. If you don't have a clean reference just give the noisy reference again.
``` ```
#launch a denoising operation on the image DATA_1_Phase_Type1_2_0.25_1.5_4_50.mat with the model experiment_xxx at the epoch 130 #launch a denoising operation on the image DATA_1_Phase_Type1_2_0.25_1.5_4_50.mat with the model experiment_xxx at the epoch 130
python3 main_holo.py --test_mode --test_noisy_img Holography/DATAEVAL/DATAEVAL/DATA_1_Phase_Type1_2_0.25_1.5_4_50.mat --test_noisy_key 'Phaseb' --test_clean_img Holography/DATAEVAL/DATAEVAL/DATA_1_Phase_Type1_2_0.25_1.5_4_50.mat --test_clean_key 'Phase' --input_dir PyTorchExperiments/experiment_xxx --epoch 130 python3 main_holo.py --test_mode --test_noisy_img Holography/DATAEVAL/DATAEVAL/DATA_1_Phase_Type1_2_0.25_1.5_4_50.mat --test_noisy_key 'Phaseb' --test_clean_img Holography/DATAEVAL/DATAEVAL/DATA_1_Phase_Type1_2_0.25_1.5_4_50.mat --test_clean_key 'Phase' --input_dir PyTorchExperiments/experiment_xxx --epoch 130
#launch a denoising operation on the image test.jpg with the model experiment_xxx at the epoch 130
python3 main_holo.py --test_mode --test_noisy_img test.jpg --test_clean_img test.jpg --input_dir PyTorchExperiments/experiment_xxx --epoch 130
``` ```
If you do not give an image to de-noise an evaluation of the entire training and testing database you start. If you do not give an image to de-noise, an evaluation of the entire training and testing database will be done start.
``` ```
#launch a denoising operation on the 25 images of Holography/DATABASE and Holography/DATAEVAL/DATAEVAL database with the model experiment_xxx at the epoch 130 #launch a denoising operation on the 25 images of Holography/DATABASE and Holography/DATAEVAL/DATAEVAL database with the model experiment_xxx at the epoch 130
python3 main_holo.py --test_mode --input_dir PyTorchExperiments/experiment_xxx --epoch 130 python3 main_holo.py --test_mode --input_dir PyTorchExperiments/experiment_xxx --epoch 130
...@@ -95,7 +110,8 @@ The results of those de-noising operation can be found in a TestImages directory ...@@ -95,7 +110,8 @@ The results of those de-noising operation can be found in a TestImages directory
Results obtained with different configurations. Values are given in terms of Phase STD Results obtained with different configurations. Values are given in terms of Phase STD
Durations are given in Day-Hours:Min:Sec with one GPU. Durations are given in Day-Hours:Min:Sec with one GPU.
``` ```
| PATTERNS 1-5 || TEST DATA | PATTERNS 1-5 || TEST DATA
Epochs | lr | train patterns | train noise | nb batches | layers | duration | MOY || DATA1 | DATA20 | VibMap || Epochs | lr | train patterns | train noise | nb batches | layers | duration | MOY || DATA1 | DATA20 | VibMap ||
3 | 0.0010 | [1-2-3-4-5] | [0,1,1.5,2,2.5] | 384 | 16 | 0-00:27:47 | 0.036 || 0.065 | 0.606 | 0.131 || 3 | 0.001 | [1-2-3-4-5] | [0,1,1.5,2,2.5] | 384 | 16 | 00-00:27:47 | 0.036 || 0.065 | 0.606 | 0.131 ||
100 | 0.001 | [1-2-3-4-5] | [0-1-1.5-2-2.5] | 384 | 16 | 00-15:25:35 | 0.029 || 0.054 | 0.599 | 0.139 ||
``` ```
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment