Commit d28b2f9a authored by Guillaume HEUSCH's avatar Guillaume HEUSCH

all the stuff for IQM notebook + reorganizing data

parent 75b85484
Pipeline #25193 passed with stage
in 1 minute and 2 seconds
This diff is collapsed.
This diff is collapsed.
#!/usr/bin/env python
# encoding: utf-8
import bob.measure
from matplotlib import pyplot
def plot_scores_distributions(scores_dev, scores_eval, title='Score Distribution', n_bins=50):
"""
Parameters
----------
scores_dev : list
The list containing negative and positive scores for the dev set
scores_eval : list
The list containing negative and positive scores for the eval set
title: string
Title of the plot
n_bins: int
Number of bins in the histogram
"""
# compute the threshold on the dev set
neg_dev = scores_dev[0]
pos_dev = scores_dev[1]
threshold = bob.measure.eer_threshold(scores_dev[0], scores_dev[1])
f, ax = pyplot.subplots(1, 2, figsize=(15, 5))
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].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].set_title('Evaluation set')
ax[1].set_xlabel("Score Value")
ax[1].set_ylabel("Probability Density")
ax[1].legend()
pyplot.show()
import numpy
import bob.io.base
import bob.io.video
import bob.io.image
import bob.ip.base
def rotate_and_save_frame(video, frame_index=0):
frame = video[frame_index]
rotated_shape = bob.ip.base.rotated_output_shape(frame, 270)
frame_rotated = numpy.ndarray(rotated_shape, dtype=numpy.float64)
bob.ip.base.rotate(frame, frame_rotated, 270)
final = frame_rotated.astype(numpy.uint8)
bob.io.base.save(final, 'data/iqm/replay-mobile/attack_print.png')
def main():
video = bob.io.base.load('data/iqm/replay-mobile/attack_client003_session01_print_fixed_tablet_photo_lightoff.mov')
rotate_and_save_frame(video)
if __name__ == "__main__":
main()
This diff is collapsed.
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