Commit 851b1c18 authored by Zohreh MOSTAANI's avatar Zohreh MOSTAANI

fixed the lists for models and makeup using only bonafide files that also had makeup

parent aab3cf8f
...@@ -5,7 +5,7 @@ AIM dataset for vulnurabitlity analysis agains makeup. Default configuration for ...@@ -5,7 +5,7 @@ AIM dataset for vulnurabitlity analysis agains makeup. Default configuration for
""" """
from bob.paper.makeup_aim.database import AIMVulunDataset from bob.paper.makeup_aim.database.aim_vuln import AIMVulnDataset
ORIGINAL_DIRECTORY = "[AIM_DIRECTORY]" ORIGINAL_DIRECTORY = "[AIM_DIRECTORY]"
...@@ -13,7 +13,7 @@ ORIGINAL_EXTENSION = ".h5" ...@@ -13,7 +13,7 @@ ORIGINAL_EXTENSION = ".h5"
ANNOTATION_DIRECTORY = "[AIM_ANNOTATION_DIRECTORY]" ANNOTATION_DIRECTORY = "[AIM_ANNOTATION_DIRECTORY]"
PROTOCOL = "grandtest" PROTOCOL = "grandtest"
database = AIMVulunDataset( database = AIMVulnDataset(
protocol=PROTOCOL, protocol=PROTOCOL,
original_directory=ORIGINAL_DIRECTORY, original_directory=ORIGINAL_DIRECTORY,
original_extension=ORIGINAL_EXTENSION, original_extension=ORIGINAL_EXTENSION,
......
...@@ -6,7 +6,7 @@ This file contains configuration to run vulunaribility analysis experiments for ...@@ -6,7 +6,7 @@ This file contains configuration to run vulunaribility analysis experiments for
#-------------------------------------------------------------------- #--------------------------------------------------------------------
# sub_directory where the results will be placed # sub_directory where the results will be placed
sub_directory = 'aim_vulun' sub_directory = 'aim_vuln'
#-------------------------------------------------------------------- #--------------------------------------------------------------------
......
...@@ -41,7 +41,7 @@ class File(VideoBioFile): ...@@ -41,7 +41,7 @@ class File(VideoBioFile):
return frame_selector(data) return frame_selector(data)
class AIMVulunDataset(FileListBioDatabase): class AIMVulnDataset(FileListBioDatabase):
""" """
A high level implementation of a Database class for AIM dataset used for vulnurabitliy analysis. A high level implementation of a Database class for AIM dataset used for vulnurabitliy analysis.
""" """
...@@ -49,7 +49,7 @@ class AIMVulunDataset(FileListBioDatabase): ...@@ -49,7 +49,7 @@ class AIMVulunDataset(FileListBioDatabase):
def __init__( def __init__(
self, self,
name="AIM_vulun", name="AIM_vuln",
original_directory=None, original_directory=None,
original_extension='.h5', original_extension='.h5',
protocol="grandtest", protocol="grandtest",
...@@ -82,11 +82,11 @@ class AIMVulunDataset(FileListBioDatabase): ...@@ -82,11 +82,11 @@ class AIMVulunDataset(FileListBioDatabase):
""" """
filelists_directory = pkg_resources.resource_filename( __name__, "/lists/aim_vulun/") filelists_directory = pkg_resources.resource_filename( __name__, "/lists/aim_vuln/")
self.filelists_directory = filelists_directory self.filelists_directory = filelists_directory
# init the parent class using super. # init the parent class using super.
super(AIMVulunDataset, self).__init__( super(AIMVulnDataset, self).__init__(
filelists_directory=filelists_directory, filelists_directory=filelists_directory,
name=name, name=name,
protocol=protocol, protocol=protocol,
...@@ -113,7 +113,7 @@ class AIMVulunDataset(FileListBioDatabase): ...@@ -113,7 +113,7 @@ class AIMVulunDataset(FileListBioDatabase):
""" """
Computes annotations for a given file object ``f``, which Computes annotations for a given file object ``f``, which
is an instance of the ``BatlPadFile`` class. is an instance of the ``File`` class.
NOTE: you can pre-compute annotation in your first experiment NOTE: you can pre-compute annotation in your first experiment
and then reuse them in other experiments setting and then reuse them in other experiments setting
......
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/24.01.18/001_01_000_0_00 001 001
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/23.01.18/009_01_000_0_00 009 009
face-station/24.01.18/010_01_000_0_00 010 010
face-station/24.01.18/011_01_000_0_00 011 011
face-station/25.01.18/012_01_000_0_00 012 012
face-station/24.01.18/013_01_000_0_00 013 013
face-station/24.01.18/014_01_000_0_00 014 014
face-station/25.01.18/015_01_000_0_00 015 015
face-station/26.01.18/017_01_000_0_00 017 017
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/29.01.18/020_01_000_0_00 020 020
face-station/29.01.18/021_01_000_0_00 021 021
face-station/29.01.18/022_01_000_0_00 022 022
face-station/29.01.18/023_01_000_0_00 023 023
face-station/29.01.18/024_01_000_0_00 024 024
face-station/29.01.18/025_01_000_0_00 025 025
face-station/30.01.18/026_01_000_0_00 026 026
face-station/30.01.18/027_01_000_0_00 027 027
face-station/30.01.18/028_01_000_0_00 028 028
face-station/30.01.18/029_01_000_0_00 029 029
face-station/30.01.18/030_01_000_0_00 030 030
face-station/30.01.18/031_01_000_0_00 031 031
face-station/31.01.18/032_01_000_0_00 032 032
face-station/31.01.18/033_01_000_0_00 033 033
face-station/31.01.18/034_01_000_0_00 034 034
face-station/31.01.18/035_01_000_0_00 035 035
face-station/31.01.18/036_01_000_0_00 036 036
face-station/07.02.18/037_02_000_0_00 037 037
face-station/01.02.18/038_01_000_0_00 038 038
face-station/01.02.18/039_01_000_0_00 039 039
face-station/01.02.18/040_01_000_0_00 040 040
face-station/01.02.18/041_01_000_0_00 041 041
face-station/07.02.18/042_02_000_0_00 042 042
face-station/01.02.18/043_01_000_0_00 043 043
face-station/07.02.18/044_02_000_0_00 044 044
face-station/07.02.18/045_02_000_0_00 045 045
face-station/01.02.18/046_01_000_0_00 046 046
face-station/02.02.18/047_01_000_0_00 047 047
face-station/02.02.18/048_01_000_0_00 048 048
face-station/02.02.18/049_01_000_0_00 049 049
face-station/02.02.18/050_01_000_0_00 050 050
face-station/02.02.18/051_01_000_0_00 051 051
face-station/02.02.18/052_01_000_0_00 052 052
face-station/02.02.18/053_01_000_0_00 053 053
face-station/02.02.18/054_01_000_0_00 054 054
face-station/02.02.18/055_01_000_0_00 055 055
face-station/07.02.18/056_02_000_0_00 056 056
face-station/02.02.18/057_01_000_0_00 057 057
face-station/02.02.18/058_01_000_0_00 058 058
face-station/07.02.18/059_02_000_0_00 059 059
face-station/02.02.18/060_01_000_0_00 060 060
face-station/02.02.18/061_01_000_0_00 061 061
face-station/06.02.18/062_02_000_0_00 062 062
face-station/07.02.18/063_02_000_0_00 063 063
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/23.05.18/073_05_000_0_00 073 073
import os
import bob.measure
import matplotlib.pyplot as plt
import numpy
from bob.bio.base.score.load import load_score
from bob.pad.base.script.vuln_figure import _iapmr_plot
from matplotlib import gridspec
np = numpy
def return_scores(scores):
print("in function return_scores")
gen = scores[scores['real_id'] == scores['claimed_id']]['score']
makeup = scores[scores['real_id'] == 'makeup']['score']
return np.ascontiguousarray(gen), np.ascontiguousarray(makeup)
def main():
# import ipdb; ipdb.set_trace()
directory = '/idiap/user/zmostaani/experiments/batl/aim_result/'
method = 'aim_vuln/grandtest/nonorm/'
filename = 'scores-dev'
scores = load_score(os.path.join(directory, method, filename))
gen, makeup = return_scores(scores)
print("deviding scores")
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:8])
gen_sim = 1 + gen
makeup_sim = 1 + makeup
line_props = dict(color="r", alpha=0.3)
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_sim, makeup_sim], labels=['Genuine', 'Makeup'],
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("Similarity Scores")
# plt.xlabel("")
plt.title("LightCNN FR")
plt.savefig(os.path.join(directory, 'boxplot-bob-new.png'))
print("plotting boxplot")
# plt.xlabel("Normalized count")
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])
title = "LightCNN FR"
spoof_label = "Makeup"
# fig, ax = plt.subplots()
# ax = plt.gcf().add_subplot()
th = bob.measure.frr_threshold([], gen_sim, 0.1)
color_scheme = {'genuine': '#2ca02c', 'impostors': '#1f77b4',
'line': '#d4257b', 'makeup': '#ff7f0e'}
alpha_scheme = {'genuine': 0.9, 'impostors': 0.8, 'spoofs': 0.6}
hatch_scheme = {'genuine': '//', 'impostors': None, 'spoofs': None}
lines = []
line = plt.hist(gen_sim, bins=10, color=color_scheme['genuine'],
alpha=alpha_scheme['genuine'],
hatch=hatch_scheme['genuine'],
label="Genuine", density=True)
lines.append(line[-1][0])
line = plt.axvline(x=th, ymin=0, ymax=1, linewidth=2,
color=color_scheme['line'], linestyle='--',
label="FNMR threshold")
lines.append(line)
line = plt.hist(makeup_sim, bins=10, color=color_scheme['makeup'],
alpha=alpha_scheme['spoofs'],
hatch=hatch_scheme['spoofs'],
density=True, label=spoof_label)
lines.append(line[-1][0])
# ax.grid(True)
hs, ls = plt.gca().get_legend_handles_labels()
# plt.sca(ax)
ax.grid(True)
# ax.legend(handletextpad=0.9)
plt.xlabel("Similarity Scores")
plt.ylabel("Normalized Count")
plt.title(title)
# plt.tight_layout()
# plt.subplots_adjust(top=0.80)
by_label = dict(zip(ls, hs))
fig.legend(by_label.values(), by_label.keys(),
loc='upper center', ncol=3, framealpha=0.5)
plt.savefig(os.path.join(directory, 'makeup-FRR-bob-new.png'))
print("ploting histogram")
if __name__ == "__main__":
main()
Markdown is supported
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