Synthesis Images noise detection metrics developed including all approaches using SVD or others compression methods

Jerome Buisine 2478fe3955 Update of script file generator преди 6 години
fichiersSVD_light 2478fe3955 Update of script file generator преди 6 години
metrics_predictions e0e8940adf Add of 2 new metrics преди 6 години
models dda7042cb6 Scripts project updates преди 6 години
.gitignore dda7042cb6 Scripts project updates преди 6 години
LICENCE e1a8d9154f Add of script generator преди 6 години
README.md dda7042cb6 Scripts project updates преди 6 години
generateAndTrainEnsemble_random.sh 1e4d9432f5 Add possibility of metric implementation quickly преди 6 години
generateAndTrainSVM.sh 6e57b1f4ab Add of mscn metric преди 6 години
generateAndTrainSVM_random.sh 6e57b1f4ab Add of mscn metric преди 6 години
generateAndTrain_maxwell.sh 3e3365f6a3 Update of train and test data преди 6 години
generate_all_data.py 2478fe3955 Update of script file generator преди 6 години
generate_data_model.py 28fa9f510c New data files generated преди 6 години
generate_data_model_random.py 28fa9f510c New data files generated преди 6 години
generate_data_model_random_maxwell.py 3e3365f6a3 Update of train and test data преди 6 години
predict_seuil_expe.py 1e4d9432f5 Add possibility of metric implementation quickly преди 6 години
predict_seuil_expe_maxwell.py dda7042cb6 Scripts project updates преди 6 години
prediction_scene.py 1053504810 Models updated преди 6 години
requirements.txt 5911c7da90 New models creation преди 6 години
runAll_maxwell.sh e0e8940adf Add of 2 new metrics преди 6 години
save_model_result_in_md.py 6e57b1f4ab Add of mscn metric преди 6 години
save_model_result_in_md_maxwell.py ceb944aeb2 Add of specific output file comparisons преди 6 години
testModelByScene.sh 1e4d9432f5 Add possibility of metric implementation quickly преди 6 години
testModelByScene_maxwell.sh 1e4d9432f5 Add possibility of metric implementation quickly преди 6 години

README.md

Noise detection using SVM

Requirements

pip install -r requirements.txt

Generate all needed data for each metrics

python generate_all_data.py --metric all

For noise detection, many metrics are available :

  • lab
  • mscn
  • low_bits_2
  • low_bits_4

You can also specify metric you want to compute :

python generate_all_data.py --metric mscn

How to use

Multiple folders and scripts are availables :

  • fichiersSVD/* : all scene files information (zones of each scene, SVD descriptor files information and so on...).
  • fichiersSVD_light/* : all scene files information (zones of each scene, SVD descriptor files information and so on...) but here with reduction of information for few scenes. Information used in our case.
  • models/*.py : all models developed to predict noise in image.
  • 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.

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)

Remark : Note here that all python script have --help command.

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 :

  • 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.
  • scenes : scenes choice for training dataset.
  • zones : zones to take for training dataset.
  • percent : percent of data amount of zone to take (choose randomly) of zone
  • sep : output csv file seperator used
  • rowindex : if 1 then row will be like that 1:xxxxx, 2:xxxxxx, ..., n:xxxxxx

Train model

This is an example of how to train a model

python models/xxxxx.py --data 'data/xxxxx.train' --output 'model_file_to_save'

Predict image using model

Now we have a model trained, we can use it with an image as input :

python metrics_predictions/predict_noisy_image_svd_lab.py --image path/to/image.png --interval "x,x" --model saved_models/xxxxxx.joblib --mode 'svdn'

The model will return only 0 or 1 :

  • 1 means noisy image is detected.
  • 0 means image seem to be not noisy.

You can also use other specific metric

python metrics_predictions/predict_noisy_image_svd_mscn.py --image path/to/image.png --interval "x,x" --model saved_models/xxxxxx.joblib --mode 'svdn'

All SVD metrics you developed need :

  • Name added into metric_choices global array variable of generate_all_data.py file.
  • A specification of how you compute the metric into generate_data_svd method of generate_all_data.py file.
  • A prediction script into metrics_predictions folder. Name need to follow this rule : predict_noisy_image_svd_xxxx.py

Predict scene using model

Now we have a model trained, we can use it with an image as input :

python prediction_scene.py --data path/to/xxxx.csv --model saved_model/xxxx.joblib --output xxxxx --scene xxxx

Remark : scene parameter expected need to be the correct name of the Scene.

Others scripts

Test model on all scene data

In order to see if a model well generalized, a bash script is available :

bash testModelByScene.sh '100' '110' 'saved_models/xxxx.joblib' 'svdne' 'lab'

Parameters list :

  • 1 : Begin of interval of data from SVD to use
  • 2 : End of interval of data from SVD to use
  • 3 : Model we want to test
  • 4 : Kind of data input used by trained model
  • 5 : Metric used by model

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.

python predict_seuil_expe.py --interval "x,x" --model 'saved_models/xxxx.joblib' --mode ["svd", "svdn", "svdne"] --metric ['lab', 'mscn', ...] --limit_detection xx

Parameters list :

  • model : mode file saved to use
  • interval : the interval of data you want to use from SVD vector.
  • mode : kind of data ['svd', 'svdn', 'svdne']; not normalize, normalize vector only and normalize together.
  • limit_detection : number of not noisy images found to stop and return threshold (integer).

Display model performance information

Another script was developed to display into Mardown format the performance of a model.

The content will be divised into two parts :

  • Predicted performance on all scenes
  • Treshold maps obtained from model on each scenes

The previous script need to already have ran to obtain and display treshold maps on this markdown file.

python save_model_result_in_md.py --interval "xx,xx" --model saved_models/xxxx.joblib --mode ["svd", "svdn", "svdne"] --metric ['lab', 'mscn'] 

Parameters list :

  • model : mode file saved to use
  • interval : the interval of data you want to use from SVD vector.
  • mode : kind of data ['svd', 'svdn', 'svdne']; not normalize, normalize vector only and normalize together.

Markdown file is saved using model name into models_info folder.

Others...

All others bash scripts are used to combine and run multiple model combinations...

How to contribute

This git project uses git-flow implementation. You are free to contribute to it.git