Commit 42f871f8 authored by Guillaume HEUSCH's avatar Guillaume HEUSCH

example on rPPG done

parent d28b2f9a
008 mask 08_03_01 0.019515650021
008 mask 08_03_02 0.275959614286
008 mask 08_03_03 0.497662247416
008 mask 08_03_04 0.042749201605
008 mask 08_03_05 0.015605724213
009 mask 09_03_01 0.176015597907
009 mask 09_03_02 0.014869927733
009 mask 09_03_03 0.093020041838
009 mask 09_03_04 0.028526340377
009 mask 09_03_05 0.208386491643
010 mask 10_03_01 0.175430353021
010 mask 10_03_02 0.027987799462
010 mask 10_03_03 0.038503050905
010 mask 10_03_04 0.001471188853
010 mask 10_03_05 0.076327101960
011 mask 11_03_01 0.100609588462
011 mask 11_03_02 0.175436628370
011 mask 11_03_03 0.100062548849
011 mask 11_03_04 0.053933547795
011 mask 11_03_05 0.016440216274
012 mask 12_03_01 0.164367803582
012 mask 12_03_02 0.043302801604
012 mask 12_03_03 0.024386666504
012 mask 12_03_04 0.033568914834
012 mask 12_03_05 0.049884397628
008 008 08_01_01 0.956579185401
008 008 08_01_02 0.932978719743
008 008 08_01_03 0.968111190761
008 008 08_01_04 0.958503015681
008 008 08_01_05 0.967271909618
008 008 08_02_01 0.922877307564
008 008 08_02_02 0.373352597571
008 008 08_02_03 0.979450500549
008 008 08_02_04 0.156740142844
008 008 08_02_05 0.628552903487
009 009 09_01_01 0.924314353997
009 009 09_01_02 0.673322500986
009 009 09_01_03 0.952365250029
009 009 09_01_04 0.979373347112
009 009 09_01_05 0.967270915267
009 009 09_02_01 0.988255439769
009 009 09_02_02 0.802356233423
009 009 09_02_03 0.428659917914
009 009 09_02_04 0.924314353997
009 009 09_02_05 0.930256347505
010 010 10_01_01 0.909212276701
010 010 10_01_02 0.916055864898
010 010 10_01_03 0.904345537187
010 010 10_01_04 0.951520786341
010 010 10_01_05 0.988177512682
010 010 10_02_01 0.380731230024
010 010 10_02_02 0.250344889122
010 010 10_02_03 0.365874111608
010 010 10_02_04 0.924314353997
010 010 10_02_05 0.786021361028
011 011 11_01_01 0.387903860227
011 011 11_01_02 0.742062714823
011 011 11_01_03 0.525778285976
011 011 11_01_04 0.725105610891
011 011 11_01_05 0.583034581320
011 011 11_02_01 0.234461874373
011 011 11_02_02 0.611572552126
011 011 11_02_03 0.924389609045
011 011 11_02_04 0.114563300815
011 011 11_02_05 0.701859458358
012 012 12_01_01 0.861052014114
012 012 12_01_02 0.870145133244
012 012 12_01_03 0.945575853860
012 012 12_01_04 0.953336803339
012 012 12_01_05 0.931627603428
012 012 12_02_01 0.920123649758
012 012 12_02_02 0.976967209834
012 012 12_02_03 0.765364732917
012 012 12_02_04 0.921648106738
012 012 12_02_05 0.958743474714
013 mask 13_03_01 0.148246603257
013 mask 13_03_02 0.025841478750
013 mask 13_03_03 0.001618762346
013 mask 13_03_04 0.093235910249
013 mask 13_03_05 0.009739134648
014 mask 14_03_01 0.567128744222
014 mask 14_03_02 0.440392853323
014 mask 14_03_03 0.476144099965
014 mask 14_03_04 0.809804788999
014 mask 14_03_05 0.296992411343
015 mask 15_03_01 0.413683623384
015 mask 15_03_02 0.035972976315
015 mask 15_03_03 0.019305002703
015 mask 15_03_04 0.634178435353
015 mask 15_03_05 0.002900618789
016 mask 16_03_01 0.048987001068
016 mask 16_03_02 0.054285930034
016 mask 16_03_03 0.047324342818
016 mask 16_03_04 0.003527740379
016 mask 16_03_05 0.010941522147
017 mask 17_03_01 0.024838562236
017 mask 17_03_02 0.074852582198
017 mask 17_03_03 0.022105432935
017 mask 17_03_04 0.209331488570
017 mask 17_03_05 0.071365305428
013 013 13_01_01 0.985472931456
013 013 13_01_02 0.918207482072
013 013 13_01_03 0.968601169561
013 013 13_01_04 0.946192156405
013 013 13_01_05 0.891634145742
013 013 13_02_01 0.930425142401
013 013 13_02_02 0.787493572187
013 013 13_02_03 0.925097852171
013 013 13_02_04 0.211782634931
013 013 13_02_05 0.915378084073
014 014 14_01_01 0.983456953008
014 014 14_01_02 0.350224200695
014 014 14_01_03 0.158669056228
014 014 14_01_04 0.924314353997
014 014 14_01_05 0.946955160342
014 014 14_02_01 0.784352851974
014 014 14_02_02 0.924314364997
014 014 14_02_03 0.975340946050
014 014 14_02_04 0.982553403267
014 014 14_02_05 0.652191965951
015 015 15_01_01 0.201670825541
015 015 15_01_02 0.924314764941
015 015 15_01_03 0.914408339313
015 015 15_01_04 0.895262173821
015 015 15_01_05 0.745345524952
015 015 15_02_01 0.580739687081
015 015 15_02_02 0.876408150533
015 015 15_02_03 0.640287434861
015 015 15_02_04 0.590121802218
015 015 15_02_05 0.716003760644
016 016 16_01_01 0.959001338552
016 016 16_01_02 0.968464135708
016 016 16_01_03 0.973590422637
016 016 16_01_04 0.841494605918
016 016 16_01_05 0.984454731337
016 016 16_02_01 0.487145718612
016 016 16_02_02 0.218645994831
016 016 16_02_03 0.797403731215
016 016 16_02_04 0.617394971350
016 016 16_02_05 0.960835725314
017 017 17_01_01 0.981292765411
017 017 17_01_02 0.969470914454
017 017 17_01_03 0.645898126896
017 017 17_01_04 0.692771607319
017 017 17_01_05 0.951621667879
017 017 17_02_01 0.860363133074
017 017 17_02_02 0.760104524998
017 017 17_02_03 0.300884529252
017 017 17_02_04 0.662446450710
017 017 17_02_05 0.209691959762
#!/usr/bin/env python
# encoding: utf-8
import numpy
import bob.measure
from matplotlib import pyplot
import bob.bio.base
def plot_scores_distributions(scores_dev, scores_eval, title='Score Distribution', n_bins=50):
def plot_scores_distributions(scores_dev, scores_eval, title='Score Distribution', n_bins=50, threshold_height=1):
"""
Parameters
----------
......@@ -29,14 +30,14 @@ def plot_scores_distributions(scores_dev, scores_eval, title='Score Distribution
f.suptitle(title, fontsize=20)
ax[0].hist(scores_dev[1], density=True, color='C1', bins=n_bins, label='Bona-fide')
ax[0].hist(scores_dev[0], density=True, color='C7', bins=n_bins, alpha=0.4, hatch='\\\\', label='Presentation Attack')
ax[0].vlines(threshold, 0, 1, colors='r', linestyles='dashed', label='EER Threshold')
ax[0].vlines(threshold, 0, threshold_height, colors='r', linestyles='dashed', label='EER Threshold')
ax[0].set_title('Development set')
ax[0].set_xlabel("Score Value")
ax[0].set_ylabel("Probability Density")
ax[0].legend()
ax[1].hist(scores_eval[1], density=True, color='C1', bins=n_bins, label='Bona-fide')
ax[1].hist(scores_eval[0], density=True, color='C7', bins=n_bins, alpha=0.4, hatch='\\\\', label='Presentation Attack')
ax[1].vlines(threshold, 0, 1, colors='r', linestyles='dashed', label='EER Threshold')
ax[1].vlines(threshold, 0, threshold_height, colors='r', linestyles='dashed', label='EER Threshold')
ax[1].set_title('Evaluation set')
ax[1].set_xlabel("Score Value")
ax[1].set_ylabel("Probability Density")
......@@ -44,3 +45,31 @@ def plot_scores_distributions(scores_dev, scores_eval, title='Score Distribution
pyplot.show()
# get the scores and remove NaNs
def get_scores(scores_it):
scores = []
for s in scores_it:
if not numpy.isnan(s[-1]):
scores.append(s[-1])
return scores
def load_scores(score_file):
scores_it = bob.bio.base.score.load.four_column(score_file)
scores = get_scores(scores_it)
return scores
def plot_det(scores_dev, scores_eval, ax_lim=[0.01, 90, 0.01, 90]):
n_points = 100
pyplot.figure(figsize=(7,5))
pyplot.title('DET curves', fontsize=16, pad=10)
bob.measure.plot.det(scores_dev[0], scores_dev[1], n_points, color='C0', linestyle='-', label='dev')
bob.measure.plot.det(scores_eval[0], scores_eval[1], n_points, color='C0', linestyle='--', label='eval')
bob.measure.plot.det_axis(ax_lim)
pyplot.xlabel('APCER (%)')
pyplot.ylabel('BPCER (%)')
pyplot.legend()
pyplot.grid(True)
pyplot.show()
This diff is collapsed.
......@@ -18,13 +18,9 @@ from bob.rppg.cvpr14.filter_utils import detrend
from bob.rppg.cvpr14.filter_utils import average
def load_and_plot_frame(image):
bob.io.image.imshow(image)
def detect_and_plot_face(image):
def detect_face(image):
bbox, quality = bob.ip.facedetect.detect_single_face(image)
face = crop_face(image, bbox, bbox.size[1])
bob.io.image.imshow(face)
return face
def build_and_plot_mask(face):
......@@ -52,9 +48,13 @@ def build_and_plot_mask(face):
bob.ip.draw.line(face_mask, (mask_points[0][0], mask_points[0][1]), (mask_points[8][0], mask_points[8][1]), (0,255,0))
# display
f, (ax1, ax2) = pyplot.subplots(1, 2, sharey=True)
f, (ax1, ax2) = pyplot.subplots(1, 2, sharey=True, figsize=(10, 20))
ax1.imshow(numpy.rollaxis(numpy.rollaxis(display_ldms, 2),2))
ax1.set_xticks([])
ax1.set_yticks([])
ax2.imshow(numpy.rollaxis(numpy.rollaxis(face_mask, 2),2))
ax2.set_xticks([])
ax2.set_yticks([])
pyplot.show()
......
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