Commit 804f5220 authored by Maria Kleppestø Mcculloch's avatar Maria Kleppestø Mcculloch
Browse files

Merge branch 'main' of...

Merge branch 'main' of https://gitlab.stud.idi.ntnu.no/mariakmc/imt4126-biometricqualitymetrics into main
parents 6d9ec6bf e4e5784e
......@@ -9,7 +9,16 @@ The library installation can be found here: https://github.com/deepinsight/insig
## Running the opertaions
In theory all 3 operations can be run in the same instance, or in three sepearate runs. It can be beneficial to perform the operationsin two runs; first compute the baselines, and then compute and plot the metrics. For details on how to perform these three operations, read the following sections:
In theory all 3 operations can be run in the same instance, or in three sepearate runs. It can be beneficial to perform the operationsin two runs; first compute the baselines, and then compute and plot the metrics. The ``QualityEvaluator`` object is the heart of all computations. The first argument when initiating this class is the instance name. In main.py this is "ArcFaceCasiaV2", although it can be anything. Just note that all filenames that are written will be tied to the instance name, so for instance a QualityEvaluator object used to compute metrics needs to have the same instance name as the QualityEvaluator objec used to plot them. One can use the same object if these operation is done in the same run.
If you need to use a different name of the metric file than the instance name, on can specify a different filename when plotting;
``QualEval.PlotMetric("DET", "focus",subnr=params[0], sampnr=params[1], metric_name="path/to/metric/focus_values")``
Using the instance name is however best.
For details on how to perform these three operations, read the following sections:
### 0. Setting project path
......@@ -18,7 +27,7 @@ In theory all 3 operations can be run in the same instance, or in three sepearat
`` projectpath = "my/project/path/" ``
### 1. Computing the baseline.
One can use the code present in main.py to compute the baseline.
One can use the code present in main.py to compute the baseline. In order to compute, one have to first init a ``QualityEvaluator`` object. Then, one needs to init the ArcFace method, and read in the dataset. One can then run the ``computeBaselines()`` method, which will compute the baselines. If one wants to save the baselines to file, one needs to call the ``saveBasline()`` mehtod. To do this main, do the following:
#### i. Uncomment the following lines in main.py:
......@@ -40,6 +49,7 @@ One can use the code present in main.py to compute the baseline.
### 2. Compute quality metrics
This can be run as long as there are some baselines (.npy file) in data/ . One does not need to have run ``computeBaselines()`` in the same run. In order to compute metrics, one needs to init a ``QualityEvaluator`` object, and run ``Detection_Arcface_init`` in order to init ArcFace. Then, one needs to call ``ComputeMetric("name", subjectnr, samplenr)``. If the metric is suported, it will be computed. Then, one needs to call the ``SaveMetric()`` if one wants the metric to be read to file. This cane be done using main by doing the following:
#### i. Uncomment the following lines in main.py:
......@@ -68,13 +78,12 @@ One can use the code present in main.py to compute the baseline.
### 3. Plot quality metrics
NB! If the metrics have not been computet (aka there is no data/[name].npy files or data/brisque/[name].csv) this will fail. Make sure the metrics have been computed, either in this or a previous run.
This can be run as long as there are some baselines (.npy file in data/), and some quality scores for the specified metric (.npy file in data/ or .csv file in data/brisque/ ). In order to plot metrics, one needs to init a ``QualityEvaluator`` object. Then, one needs to call ``PlotMetric("Method", "Metric", subnr=[subnr], samnr=[sampnr])``. If the metric is suported, it will be plotted. In order to do this in main, do the following:
#### i. Uncomment the following lines in main.py:
``QualEval = QualityEvaluator("ArcFaceCasiaV2", projectpath, imgsdir, "subjectnr/samplenr")``
``QualEval.PlotMetric("EDC", "focus",subnr=params[0], sampnr=params[1])``
......
......@@ -8,35 +8,6 @@ from qualityEvaluation import ValueHandling as QualityTemp
from utils.baseScore import BaseHandler
import matplotlib.pyplot as mpl
'''
Perform Quality Assesment
Calcualting the Baseline scores:
QualEval = QualityEvaluator("ArcFaceCasiaV2", projectpath, imgsdir, "subjectnr/samplenr")
QualEval.ArcFace_init()
QualEval.readInDataset(params, projectpath, imgsdir, "ArcFaceCasia", True )
QualEval.ComputeBaselines()
QualEval.SaveBaslines()
Computing the quality metrics:
QualEval = QualityEvaluator("ArcFaceCasiaV2", projectpath, imgsdir, "subjectnr/samplenr")
QualEval.Detection_Arcface_init()
QualEval.ComputeMetric("sharpness", params[0], params[1])
QualEval.ComputeMetric("focus", params[0], params[1])
QualEval.SaveMetric("sharpness")
QualEval.SaveMetric("focus")
Plotting:
QualEval = QualityEvaluator("ArcFaceCasiaV2", projectpath, imgsdir, "subjectnr/samplenr")
QualEval.PlotMetric("EDC", "focus",subnr=params[0], sampnr=params[1])
QualEval.PlotMetric("EDC", "sharpness",subnr=params[0], sampnr=params[1])
QualEval.PlotMetric("EDC", "brisque",subnr=params[0], sampnr=params[1], metric_name="data/brisque/quality_values_aug")
QualEval.PlotMetric("DET", "focus",subnr=params[0], sampnr=params[1])
QualEval.PlotMetric("DET", "sharpness",subnr=params[0], sampnr=params[1])
QualEval.PlotMetric("DET", "brisque",subnr=params[0], sampnr=params[1], metric_name="data/brisque/quality_values_aug")
QualEval.PlotDETCurve(params[0],params[1])
'''
# Init vars
#params = [51, 5]
......@@ -84,7 +55,7 @@ print("--* Saving Baselines")
## STEP 2: COMPUTE METRICS ##
######################################
## NB! REMEMBER TO UNCOMMOENT QualEval initiation ON LINE 63
## NB! REMEMBER TO UNCOMMOENT the QualEval initiation ON LINE 35
'''
# Compute metrics
......@@ -106,7 +77,7 @@ QualEval.SaveMetric("focus")
## STEP 3: PLOT METRICS ##
##########################
## NB! REMEMBER TO UNCOMMOENT QualEval INIT ON LINE 64 AND QualEval.Detection_Arcface() ON LINE 92
## NB! REMEMBER TO UNCOMMOENT the QualEval initiation ON LINE 35 AND QualEval.Detection_Arcface_init() ON LINE 63
'''
print("--* Plotting Metrics")
......
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