Commit 72a52edf authored by Ketan Kotwal's avatar Ketan Kotwal

Merge branch 'vulun' into 'master'

Added experiments for vulnerability analysis

See merge request !1
parents 9adae2fb 1ac058bd
Pipeline #34410 failed with stages
in 14 minutes and 28 seconds
#!/usr/bin/env python
"""
AIM dataset for vulnurabitlity analysis agains makeup. Default configuration for grandtest protocol
"""
from bob.paper.makeup_aim.database.aim_vuln import AIMVulnDataset
ORIGINAL_DIRECTORY = "[AIM_DIRECTORY]"
ORIGINAL_EXTENSION = ".h5"
ANNOTATION_DIRECTORY = "[AIM_ANNOTATION_DIRECTORY]"
PROTOCOL = "grandtest"
database = AIMVulnDataset(
protocol=PROTOCOL,
original_directory=ORIGINAL_DIRECTORY,
original_extension=ORIGINAL_EXTENSION,
annotation_directory=ANNOTATION_DIRECTORY,
training_depends_on_protocol=True,
)
groups = ["dev"]
#----------------------------------------------------------
#!/usr/bin/env python
"""
This file contains configuration to run vulunaribility analysis experiments for AIM dataset.
"""
#--------------------------------------------------------------------
# sub_directory where the results will be placed
sub_directory = 'aim_vuln'
#--------------------------------------------------------------------
# define preprocessor:
from bob.pad.face.preprocessor import FaceCropAlign
from bob.bio.video.preprocessor import Wrapper
from bob.bio.video.utils import FrameSelector
# parameters and constants
FACE_SIZE = 128
RGB_OUTPUT_FLAG = False
USE_FACE_ALIGNMENT = True
ALIGNMENT_TYPE = "lightcnn"
MAX_IMAGE_SIZE = None
FACE_DETECTION_METHOD = None
MIN_FACE_SIZE = 50
_image_preprocessor = FaceCropAlign(face_size=FACE_SIZE,
rgb_output_flag=RGB_OUTPUT_FLAG,
use_face_alignment=USE_FACE_ALIGNMENT,
alignment_type=ALIGNMENT_TYPE,
max_image_size=MAX_IMAGE_SIZE,
face_detection_method=FACE_DETECTION_METHOD,
min_face_size=MIN_FACE_SIZE,
)
_frame_selector = FrameSelector(selection_style = "spread")
preprocessor = Wrapper(preprocessor = _image_preprocessor, frame_selector = _frame_selector)
#--------------------------------------------------------------------
# define extractor:
from bob.paper.makeup_aim.extractor import FICNN
from bob.bio.video.extractor import Wrapper
from bob.extension import rc
import os
_model_dir = rc.get("LIGHTCNN9_MODEL_DIRECTORY")
_model_name = "LightCNN_9Layers_checkpoint.pth.tar"
_model_file = os.path.join(_model_dir, _model_name)
if not os.path.exists(_model_file):
print("Error: Could not find the LightCNN-9 model at [{}].\nPlease follow the download instructions from README".format(_model_dir))
exit(0)
extractor = Wrapper(FICNN(model_file=_model_file))
#--------------------------------------------------------------------
# define algorithm:
from bob.bio.base.config.algorithm.distance_cosine import algorithm
from bob.bio.video.algorithm import Wrapper
algorithm = Wrapper(algorithm)
#--------------------------------------------------------------------
\ No newline at end of file
......@@ -161,7 +161,7 @@ class AIMDatabase(FileListPadDatabase):
NOTE: you can pre-compute annotation in your first experiment
and then reuse them in other experiments setting
``self.annotations_temp_dir`` path of this class, where
``self.annotations_directory`` path of this class, where
precomputed annotations will be saved.
**Parameters:**
......
"""
Implementation of dataset interface of AIM for Face Recognition using RGB images.
@author: Zohreh Mostaani
"""
# Imports
from bob.bio.base.database import FileListBioDatabase
from bob.bio.video.database import VideoBioFile
from bob.bio.video import FrameSelector
from bob.io.base import HDF5File, create_directories_safe
from bob.pad.face.preprocessor.FaceCropAlign import detect_face_landmarks_in_image
import numpy as np
import json
import os
import pkg_resources
import logging
logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)
#--------------------------------------------------------------------
class File(VideoBioFile):
"""
The file interface for RGB data.
"""
def load(self, directory=None, extension=None,
frame_selector=FrameSelector()):
filepath = self.make_path(directory, extension)
with HDF5File(filepath) as f:
data = f['/intelsr300_bgr']
# bgr to rgb
data = data[..., ::-1]
# to bob format
data = np.moveaxis(data, -1, 1)
return frame_selector(data)
class AIMVulnDataset(FileListBioDatabase):
"""
A high level implementation of a Database class for AIM dataset used for vulnerability analysis.
"""
def __init__(
self,
name="AIM_vuln",
original_directory=None,
original_extension='.h5',
protocol="grandtest",
annotation_directory=None,
annotation_extension='.json',
annotation_type='json',
models_depend_on_protocol=True,
bio_file_class=File,
use_dense_probe_file_list=False,
groups="dev",
**kwargs):
"""
**Parameters:**
``original_directory`` : str or None
original directory refers to the location of AIM_vuln parent directory
``original_extension`` : str or None
extension of original data
``groups`` : str or [str]
The groups for which the clients should be returned.
Usually, groups are one or more elements of ['train', 'dev', 'eval'].
Default: 'dev'.
``protocol`` : str
The protocol for which the clients should be retrieved.
Default: 'grandtest'.
"""
filelists_directory = pkg_resources.resource_filename( __name__, "/lists/aim_vuln/")
self.filelists_directory = filelists_directory
# init the parent class using super.
super(AIMVulnDataset, self).__init__(
filelists_directory=filelists_directory,
name=name,
protocol=protocol,
original_directory=original_directory,
original_extension=original_extension,
annotation_directory=annotation_directory,
annotation_extension=annotation_extension,
annotation_type=annotation_type,
bio_file_class=bio_file_class,
models_depend_on_protocol=models_depend_on_protocol,
**kwargs)
self.bio_file_class=bio_file_class
self.annotation_directory = annotation_directory
self.landmark_detect_method = "mtcnn"
self.protocol = protocol
logger.info("Dataset: {}".format(self.name))
logger.info("Original directory: {}; Annotation directory: {}".format(self.original_directory, self.annotation_directory))
#--------------------------------------------------------------------
def annotations(self, f):
"""
Computes annotations for a given file object ``f``, which
is an instance of the ``File`` class.
NOTE: you can pre-compute annotation in your first experiment
and then reuse them in other experiments setting
``self.annotation_directory`` path of this class, where
precomputed annotations will be saved.
**Parameters:**
``f`` : :py:class:`object`
An instance of ``File`` defined above.
**Returns:**
``annotations`` : :py:class:`dict`
A dictionary containing annotations for
each frame in the video.
Dictionary structure:
``annotations = {'1': frame1_dict, '2': frame1_dict, ...}``.
Where
``frameN_dict`` contains coordinates of the
face bounding box and landmarks in frame N.
"""
file_path = os.path.join(self.annotation_directory, f.path + ".json")
# If annotations do not exist, then generate.
if not os.path.isfile(file_path):
video = f.load(directory=self.original_directory,
extension=self.original_extension)
annotations = {}
for idx, image in enumerate(video.as_array()):
frame_annotations = detect_face_landmarks_in_image(
image, method=self.landmark_detect_method)
if frame_annotations:
annotations[str(idx)] = frame_annotations
# if directory is not an empty string
if self.annotation_directory:
create_directories_safe(
directory=os.path.split(file_path)[0], dryrun=False)
with open(file_path, 'w+') as json_file:
json_file.write(json.dumps(annotations))
# if file with annotations exists load them from file
else:
with open(file_path, 'r') as json_file:
annotations = json.load(json_file)
# if dictionary is empty
if not annotations:
logger.warning("Empty annotations for %s", f.path)
return None
return annotations
#--------------------------------------------------------------------
\ No newline at end of file
face-station/01.02.18/002_01_000_0_00 002 002
face-station/17.01.18/003_01_000_0_00 003 003
face-station/17.01.18/004_01_000_0_00 004 004
face-station/18.01.18/005_01_000_0_00 005 005
face-station/22.01.18/006_01_000_0_00 006 006
face-station/22.01.18/007_01_000_0_00 007 007
face-station/26.01.18/008_01_000_0_00 008 008
face-station/25.01.18/012_01_000_0_00 012 012
face-station/18.01.18/018_01_000_0_00 018 018
face-station/31.01.18/019_01_000_0_00 019 019
face-station/01.02.18/038_01_000_0_00 038 038
face-station/30.04.18/064_05_000_0_00 064 064
face-station/01.05.18/065_07_000_0_00 065 065
face-station/23.04.18/066_05_000_0_00 066 066
face-station/23.04.18/067_05_000_0_00 067 067
face-station/22.05.18/068_05_000_0_00 068 068
face-station/15.05.18/069_05_000_0_00 069 069
face-station/04.05.18/070_05_000_0_00 070 070
face-station/04.05.18/071_05_000_0_00 071 071
face-station/23.05.18/072_07_000_0_00 072 072
face-station/08.02.18/002_02_000_0_00 002 002 002
face-station/08.02.18/002_03_000_0_00 002 002 002
face-station/04.05.18/002_05_000_0_00 002 002 002
face-station/07.05.18/002_06_000_0_00 002 002 002
face-station/08.05.18/002_07_000_0_00 002 002 002
face-station/06.02.18/003_02_000_0_00 003 003 003
face-station/14.02.18/003_03_000_0_00 003 003 003
face-station/02.05.18/003_05_000_0_00 003 003 003
face-station/03.05.18/003_06_000_0_00 003 003 003
face-station/04.05.18/003_07_000_0_00 003 003 003
face-station/07.02.18/004_02_000_0_00 004 004 004
face-station/15.02.18/004_03_000_0_00 004 004 004
face-station/04.05.18/004_06_000_0_00 004 004 004
face-station/15.05.18/004_05_000_0_00 004 004 004
face-station/16.05.18/004_07_000_0_00 004 004 004
face-station/08.02.18/005_02_000_0_00 005 005 005
face-station/12.02.18/005_03_000_0_00 005 005 005
face-station/15.05.18/005_05_000_0_00 005 005 005
face-station/23.05.18/005_07_000_0_00 005 005 005
face-station/24.05.18/005_06_000_0_00 005 005 005
face-station/08.02.18/006_02_000_0_00 006 006 006
face-station/15.02.18/006_03_000_0_00 006 006 006
face-station/15.05.18/006_05_000_0_00 006 006 006
face-station/23.05.18/006_07_000_0_00 006 006 006
face-station/25.05.18/006_06_000_0_00 006 006 006
face-station/06.02.18/007_02_000_0_00 007 007 007
face-station/13.02.18/007_03_000_0_00 007 007 007
face-station/15.05.18/007_05_000_0_00 007 007 007
face-station/16.05.18/007_07_000_0_00 007 007 007
face-station/22.05.18/007_06_000_0_00 007 007 007
face-station/07.02.18/008_02_000_0_00 008 008 008
face-station/14.02.18/008_03_000_0_00 008 008 008
face-station/22.05.18/008_05_000_0_00 008 008 008
face-station/24.05.18/008_06_000_0_00 008 008 008
face-station/25.05.18/008_07_000_0_00 008 008 008
face-station/27.02.18/012_02_000_0_00 012 012 012
face-station/27.02.18/012_03_000_0_00 012 012 012
face-station/16.05.18/012_07_000_0_00 012 012 012
face-station/23.05.18/012_06_000_0_00 012 012 012
face-station/24.05.18/012_05_000_0_00 012 012 012
face-station/06.02.18/018_02_000_0_00 018 018 018
face-station/14.02.18/018_03_000_0_00 018 018 018
face-station/15.05.18/018_05_000_0_00 018 018 018
face-station/22.05.18/018_06_000_0_00 018 018 018
face-station/23.05.18/018_07_000_0_00 018 018 018
face-station/08.02.18/019_02_000_0_00 019 019 019
face-station/14.02.18/019_03_000_0_00 019 019 019
face-station/15.05.18/019_05_000_0_00 019 019 019
face-station/16.05.18/019_07_000_0_00 019 019 019
face-station/23.05.18/019_06_000_0_00 019 019 019
face-station/08.02.18/038_02_000_0_00 038 038 038
face-station/14.02.18/038_03_000_0_00 038 038 038
face-station/01.05.18/038_05_000_0_00 038 038 038
face-station/04.05.18/038_06_000_0_00 038 038 038
face-station/07.05.18/038_07_000_0_00 038 038 038
face-station/01.05.18/064_06_000_0_00 064 064 064
face-station/03.05.18/064_07_000_0_00 064 064 064
face-station/01.05.18/065_05_000_0_00 065 065 065
face-station/01.05.18/065_06_000_0_00 065 065 065
face-station/23.04.18/066_06_000_0_00 066 066 066
face-station/23.04.18/066_07_000_0_00 066 066 066
face-station/24.04.18/067_06_000_0_00 067 067 067
face-station/24.04.18/067_07_000_0_00 067 067 067
face-station/22.05.18/068_06_000_0_00 068 068 068
face-station/23.05.18/068_07_000_0_00 068 068 068
face-station/16.05.18/069_07_000_0_00 069 069 069
face-station/22.05.18/069_06_000_0_00 069 069 069
face-station/07.05.18/070_06_000_0_00 070 070 070
face-station/16.05.18/070_07_000_0_00 070 070 070
face-station/07.05.18/071_06_000_0_00 071 071 071
face-station/08.05.18/071_07_000_0_00 071 071 071
face-station/23.05.18/072_05_000_0_00 072 072 072
face-station/23.05.18/072_06_000_0_00 072 072 072
face-station/16.04.18/974_06_012_5_26 012 012 makeup
face-station/16.04.18/974_07_012_5_26 012 012 makeup
face-station/16.04.18/981_07_003_5_19 003 003 makeup
face-station/16.04.18/984_05_019_5_16 019 019 makeup
face-station/16.04.18/982_05_003_5_18 003 003 makeup
face-station/16.04.18/982_06_003_5_18 003 003 makeup
face-station/16.04.18/982_07_003_5_18 003 003 makeup
face-station/16.04.18/981_05_003_5_19 003 003 makeup
face-station/16.04.18/981_06_003_5_19 003 003 makeup
face-station/16.04.18/980_05_003_5_20 003 003 makeup
face-station/16.04.18/980_06_003_5_20 003 003 makeup
face-station/16.04.18/980_07_003_5_20 003 003 makeup
face-station/16.04.18/979_07_006_5_21 006 006 makeup
face-station/16.04.18/979_05_006_5_21 006 006 makeup
face-station/16.04.18/979_06_006_5_21 006 006 makeup
face-station/16.04.18/976_06_012_5_24 012 012 makeup
face-station/16.04.18/977_05_006_5_23 006 006 makeup
face-station/16.04.18/977_06_006_5_23 006 006 makeup
face-station/16.04.18/976_05_012_5_24 012 012 makeup
face-station/16.04.18/976_07_012_5_24 012 012 makeup
face-station/16.04.18/975_07_012_5_25 012 012 makeup
face-station/16.04.18/975_05_012_5_25 012 012 makeup
face-station/16.04.18/975_06_012_5_25 012 012 makeup
face-station/16.04.18/974_05_012_5_26 012 012 makeup
face-station/16.04.18/984_06_019_5_16 019 019 makeup
face-station/16.04.18/984_07_019_5_16 019 019 makeup
face-station/16.04.18/983_07_064_5_17 064 064 makeup
face-station/16.04.18/983_05_064_5_17 064 064 makeup
face-station/16.04.18/983_06_064_5_17 064 064 makeup
face-station/16.04.18/973_07_019_5_27 019 019 makeup
face-station/16.04.18/973_05_019_5_27 019 019 makeup
face-station/16.04.18/973_06_019_5_27 019 019 makeup
face-station/16.04.18/972_05_019_5_28 019 019 makeup
face-station/16.04.18/972_06_019_5_28 019 019 makeup
face-station/16.04.18/972_07_019_5_28 019 019 makeup
face-station/16.04.18/978_05_006_5_22 006 006 makeup
face-station/16.04.18/978_06_006_5_22 006 006 makeup
face-station/16.04.18/978_07_006_5_22 006 006 makeup
face-station/16.04.18/977_07_006_5_23 006 006 makeup
face-station/17.04.18/970_05_012_5_30 012 012 makeup
face-station/17.04.18/970_06_012_5_30 012 012 makeup
face-station/17.04.18/970_07_012_5_30 012 012 makeup
face-station/17.04.18/969_07_012_5_31 012 012 makeup
face-station/17.04.18/969_05_012_5_31 012 012 makeup
face-station/17.04.18/969_06_012_5_31 012 012 makeup
face-station/17.04.18/968_05_065_5_32 065 065 makeup
face-station/17.04.18/968_06_065_5_32 065 065 makeup
face-station/17.04.18/968_07_065_5_32 065 065 makeup
face-station/17.04.18/961_07_066_5_39 066 066 makeup
face-station/17.04.18/965_07_038_5_35 038 038 makeup
face-station/17.04.18/965_05_038_5_35 038 038 makeup
face-station/17.04.18/965_06_038_5_35 038 038 makeup
face-station/17.04.18/964_05_038_5_36 038 038 makeup
face-station/17.04.18/964_07_038_5_36 038 038 makeup
face-station/17.04.18/963_07_038_5_37 038 038 makeup
face-station/17.04.18/963_05_038_5_37 038 038 makeup
face-station/17.04.18/963_06_038_5_37 038 038 makeup
face-station/17.04.18/962_05_066_5_38 066 066 makeup
face-station/17.04.18/962_06_066_5_38 066 066 makeup
face-station/17.04.18/962_07_066_5_38 066 066 makeup
face-station/17.04.18/959_07_018_5_41 018 018 makeup
face-station/17.04.18/959_05_018_5_41 018 018 makeup
face-station/17.04.18/959_06_018_5_41 018 018 makeup
face-station/17.04.18/958_05_018_5_42 018 018 makeup
face-station/17.04.18/958_06_018_5_42 018 018 makeup
face-station/17.04.18/958_07_018_5_42 018 018 makeup
face-station/17.04.18/957_07_004_5_43 004 004 makeup
face-station/17.04.18/957_05_004_5_43 004 004 makeup
face-station/17.04.18/957_06_004_5_43 004 004 makeup
face-station/17.04.18/956_05_004_5_44 004 004 makeup
face-station/17.04.18/956_06_004_5_44 004 004 makeup
face-station/17.04.18/956_07_004_5_44 004 004 makeup
face-station/17.04.18/955_07_004_5_45 004 004 makeup
face-station/17.04.18/955_05_004_5_45 004 004 makeup
face-station/17.04.18/955_06_004_5_45 004 004 makeup
face-station/17.04.18/961_05_066_5_39 066 066 makeup
face-station/17.04.18/967_07_065_5_33 065 065 makeup
face-station/17.04.18/967_05_065_5_33 065 065 makeup
face-station/17.04.18/967_06_065_5_33 065 065 makeup
face-station/17.04.18/966_05_065_5_34 065 065 makeup
face-station/17.04.18/966_06_065_5_34 065 065 makeup
face-station/17.04.18/966_07_065_5_34 065 065 makeup
face-station/17.04.18/964_06_038_5_36 038 038 makeup
face-station/17.04.18/961_06_066_5_39 066 066 makeup
face-station/17.04.18/960_05_066_5_40 066 066 makeup
face-station/17.04.18/960_06_066_5_40 066 066 makeup
face-station/17.04.18/960_07_066_5_40 066 066 makeup
face-station/17.04.18/971_07_012_5_29 012 012 makeup
face-station/17.04.18/971_05_012_5_29 012 012 makeup
face-station/17.04.18/971_06_012_5_29 012 012 makeup
face-station/25.04.18/940_05_069_5_60 069 069 makeup
face-station/25.04.18/940_06_069_5_60 069 069 makeup
face-station/25.04.18/947_05_008_5_53 008 008 makeup
face-station/25.04.18/947_06_008_5_53 008 008 makeup
face-station/25.04.18/947_07_008_5_53 008 008 makeup
face-station/25.04.18/944_07_005_5_56 005 005 makeup
face-station/25.04.18/944_05_005_5_56 005 005 makeup
face-station/25.04.18/944_06_005_5_56 005 005 makeup
face-station/25.04.18/943_05_005_5_57 005 005 makeup
face-station/25.04.18/943_06_005_5_57 005 005 makeup
face-station/25.04.18/946_07_008_5_54 008 008 makeup
face-station/25.04.18/951_05_068_5_49 068 068 makeup
face-station/25.04.18/951_06_068_5_49 068 068 makeup
face-station/25.04.18/954_07_067_5_46 067 067 makeup
face-station/25.04.18/954_05_067_5_46 067 067 makeup
face-station/25.04.18/954_06_067_5_46 067 067 makeup
face-station/25.04.18/953_05_067_5_47 067 067 makeup
face-station/25.04.18/953_06_067_5_47 067 067 makeup
face-station/25.04.18/953_07_067_5_47 067 067 makeup
face-station/25.04.18/952_07_067_5_48 067 067 makeup
face-station/25.04.18/952_05_067_5_48 067 067 makeup
face-station/25.04.18/952_06_067_5_48 067 067 makeup
face-station/25.04.18/950_07_068_5_50 068 068 makeup
face-station/25.04.18/950_05_068_5_50 068 068 makeup
face-station/25.04.18/946_05_008_5_54 008 008 makeup
face-station/25.04.18/949_05_068_5_51 068 068 makeup
face-station/25.04.18/949_06_068_5_51 068 068 makeup
face-station/25.04.18/949_07_068_5_51 068 068 makeup
face-station/25.04.18/948_07_008_5_52 008 008 makeup
face-station/25.04.18/948_05_008_5_52 008 008 makeup
face-station/25.04.18/948_06_008_5_52 008 008 makeup
face-station/25.04.18/945_05_005_5_55 005 005 makeup
face-station/25.04.18/942_07_069_5_58 069 069 makeup
face-station/25.04.18/946_06_008_5_54 008 008 makeup
face-station/25.04.18/942_05_069_5_58 069 069 makeup
face-station/25.04.18/951_07_068_5_49 068 068 makeup
face-station/25.04.18/945_06_005_5_55 005 005 makeup
face-station/25.04.18/950_06_068_5_50 068 068 makeup
face-station/25.04.18/945_07_005_5_55 005 005 makeup
face-station/25.04.18/943_07_005_5_57 005 005 makeup
face-station/25.04.18/942_06_069_5_58 069 069 makeup
face-station/25.04.18/941_05_069_5_59 069 069 makeup
face-station/25.04.18/941_06_069_5_59 069 069 makeup
face-station/25.04.18/941_07_069_5_59 069 069 makeup
face-station/25.04.18/940_07_069_5_60 069 069 makeup
face-station/02.05.18/929_07_007_5_71 007 007 makeup
face-station/02.05.18/938_07_012_5_62 012 012 makeup
face-station/02.05.18/938_05_012_5_62 012 012 makeup
face-station/02.05.18/938_06_012_5_62 012 012 makeup
face-station/02.05.18/933_05_006_5_67 006 006 makeup
face-station/02.05.18/933_07_006_5_67 006 006 makeup
face-station/02.05.18/933_06_006_5_67 006 006 makeup
face-station/02.05.18/939_05_012_5_61 012 012 makeup
face-station/02.05.18/939_06_012_5_61 012 012 makeup
face-station/02.05.18/939_07_012_5_61 012 012 makeup
face-station/02.05.18/937_05_012_5_63 012 012 makeup
face-station/02.05.18/937_06_012_5_63 012 012 makeup
face-station/02.05.18/935_07_004_5_65 004 004 makeup
face-station/02.05.18/936_07_004_5_64 004 004 makeup
face-station/02.05.18/936_05_004_5_64 004 004 makeup
face-station/02.05.18/936_06_004_5_64 004 004 makeup
face-station/02.05.18/935_05_004_5_65 004 004 makeup
face-station/02.05.18/935_06_004_5_65 004 004 makeup
face-station/02.05.18/934_07_004_5_66 004 004 makeup
face-station/02.05.18/934_05_004_5_66 004 004 makeup
face-station/02.05.18/934_06_004_5_66 004 004 makeup
face-station/02.05.18/932_05_006_5_68 006 006 makeup
face-station/02.05.18/932_07_006_5_68 006 006 makeup
face-station/02.05.18/932_06_006_5_68 006 006 makeup
face-station/02.05.18/931_05_006_5_69 006 006 makeup
face-station/02.05.18/931_07_006_5_69 006 006 makeup
face-station/02.05.18/931_06_006_5_69 006 006 makeup
face-station/02.05.18/930_05_007_5_70 007 007 makeup
face-station/02.05.18/930_06_007_5_70 007 007 makeup
face-station/02.05.18/929_05_007_5_71 007 007 makeup
face-station/02.05.18/928_05_007_5_72 007 007 makeup
face-station/02.05.18/928_07_007_5_72 007 007 makeup
face-station/02.05.18/928_06_007_5_72 007 007 makeup
face-station/02.05.18/937_07_012_5_63 012 012 makeup
face-station/02.05.18/929_06_007_5_71 007 007 makeup
face-station/02.05.18/930_07_007_5_70 007 007 makeup
face-station/03.05.18/922_07_070_5_78 070 070 makeup
face-station/03.05.18/922_05_070_5_78 070 070 makeup
face-station/03.05.18/922_06_070_5_78 070 070 makeup
face-station/03.05.18/916_06_019_5_84 019 019 makeup
face-station/03.05.18/925_05_002_5_75 002 002 makeup
face-station/03.05.18/924_07_070_5_76 070 070 makeup
face-station/03.05.18/926_07_002_5_74 002 002 makeup
face-station/03.05.18/926_05_002_5_74 002 002 makeup
face-station/03.05.18/926_06_002_5_74 002 002 makeup
face-station/03.05.18/923_06_070_5_77 070 070 makeup
face-station/03.05.18/925_06_002_5_75 002 002 makeup
face-station/03.05.18/925_07_002_5_75 002 002 makeup
face-station/03.05.18/924_05_070_5_76 070 070 makeup
face-station/03.05.18/924_06_070_5_76 070 070 makeup
face-station/03.05.18/923_05_070_5_77 070 070 makeup
face-station/03.05.18/921_05_071_5_79 071 071 makeup
face-station/03.05.18/923_07_070_5_77 070 070 makeup
face-station/03.05.18/921_06_071_5_79 071 071 makeup
face-station/03.05.18/921_07_071_5_79 071 071 makeup
face-station/03.05.18/920_07_071_5_80 071 071 makeup
face-station/03.05.18/920_05_071_5_80 071 071 makeup
face-station/03.05.18/920_06_071_5_80 071 071 makeup
face-station/03.05.18/919_05_071_5_81 071 071 makeup
face-station/03.05.18/919_06_071_5_81 071 071 makeup
face-station/03.05.18/919_07_071_5_81 071 071 makeup
face-station/03.05.18/914_07_072_5_86 072 072 makeup
face-station/03.05.18/918_06_019_5_82 019 019 makeup
face-station/03.05.18/918_07_019_5_82 019 019 makeup
face-station/03.05.18/918_05_019_5_82 019 019 makeup
face-station/03.05.18/915_05_072_5_85 072 072 makeup
face-station/03.05.18/917_05_019_5_83 019 019 makeup
face-station/03.05.18/917_07_019_5_83 019 019 makeup
face-station/03.05.18/917_06_019_5_83 019 019 makeup
face-station/03.05.18/916_05_019_5_84 019 019 makeup
face-station/03.05.18/916_07_019_5_84 019 019 makeup
face-station/03.05.18/915_06_072_5_85 072 072 makeup
face-station/03.05.18/915_07_072_5_85 072 072 makeup
face-station/03.05.18/913_05_072_5_87 072 072 makeup
face-station/03.05.18/914_05_072_5_86 072 072 makeup
face-station/03.05.18/914_06_072_5_86 072 072 makeup
face-station/03.05.18/913_06_072_5_87 072 072 makeup
face-station/03.05.18/913_07_072_5_87 072 072 makeup
face-station/03.05.18/927_05_002_5_73 002 002 makeup
face-station/03.05.18/927_06_002_5_73 002 002 makeup
face-station/03.05.18/927_07_002_5_73 002 002 makeup
#!/usr/bin/env python
"""
Plots box-plot and histogram for similarity scores for face recognition system.
Usage:
plot_vuln.py [options] <scores>
plot_vuln.py --help
Options:
-h --help Show this screen.
-o <path>, --output=<path> The path to which the plots will be saved [default: ]
"""
import os
from docopt import docopt
import bob.measure
import matplotlib.pyplot as plt
import numpy as np
from bob.bio.base.score.load import load_score
from matplotlib import gridspec
#--------------------------------------------------------------------
# Here are the global names used for the plots
plot_title = "LightCNN FR"
genuine_label = 'Genuine'
makeup_label = 'Makeup'
# box-plot
box_plot_filename = 'box-plot'
box_plot_ylabel = 'Similarity Scores'
# histogram plot
historgram_filename = 'hist-plot'
line_label = 'FNMR threshold'
hist_plot_xlabel = 'Similarity Scores'
hist_plot_ylabel = 'Normalized Count'
#--------------------------------------------------------------------
# separating genuine and makeup scores
def return_similarity_scores(scores):
'''
Separates the necessary scores from the score list for genuine and makeup.
'''
gen = scores[scores['real_id'] == scores['claimed_id']]['score']
makeup = scores[scores['real_id'] == 'makeup']['score']
gen_sim = 1 + np.ascontiguousarray(gen)
makeup_sim = 1 + np.ascontiguousarray(makeup)
return gen_sim, makeup_sim
#--------------------------------------------------------------------
# plotting the box-plot
def plot_box_plot(gen_scores, makeup_scores, output):
'''
The box plots to show the effect of makeup on FR system
- gen_scores: the scores for genuine faces without makeup
- makeup_scores: the scores for faces with makeup
- output: The file to which the plot will be saved.
'''
plt.style.use('default')
plt.rcParams['figure.figsize'] = (4, 3)
plt.rcParams['figure.constrained_layout.use'] = True
fig = plt.figure()
gs = gridspec.GridSpec(9, 1, figure=fig)
ax = plt.gcf().add_subplot(gs[1:9])
bbox_props = dict(color="b", alpha=0.9)
flier_props = dict(marker="+", markersize=4, markeredgecolor="g")
whis_props = [5, 95]
whisker_props = dict(linestyle='--', dashes=(5, 5))
median_props = dict(color="r")
bp = ax.boxplot([gen_scores, makeup_scores], labels=[genuine_label, makeup_label],
patch_artist=False, autorange=True, flierprops=flier_props,
boxprops=bbox_props,
whiskerprops=whisker_props,
medianprops=median_props,
whis=whis_props,
widths=0.25,
)
top = 1
bottom = 0
ax.set_ylim(bottom, top)
ax.set_aspect(1.5)
for line in bp['medians']:
# get position data for median line
x, y = line.get_xydata()[1] # top of median line
# overlay median value
ax.annotate(f"{y:.2f}", (x, y))
plt.ylabel(box_plot_ylabel)
plt.title(plot_title)
plt.savefig(output)
plt.close()
#--------------------------------------------------------------------
# plotting the histogram