Create a new mobile protocol. This one is no gender specific

Patching client function

Updated test cases
parent c8251d8b
Pipeline #42486 passed with stage
in 4 minutes and 19 seconds
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
""" """
import os import os
from sqlalchemy import and_
from .models import * from .models import *
def nodot(item): def nodot(item):
...@@ -682,6 +682,9 @@ def add_protocols(session, verbose): ...@@ -682,6 +682,9 @@ def add_protocols(session, verbose):
probe = [['mobile'],['r', 'f']] probe = [['mobile'],['r', 'f']]
gender_male = 'male' gender_male = 'male'
gender_female = 'female' gender_female = 'female'
gender_both = 'both'
protocol_definitions['mobile0-male-female'] = [clients_male+clients_female, train_mobile, enroll_mobile, probe, gender_both]
protocol_definitions['mobile0-male'] = [clients_male, train_mobile, enroll_mobile, probe, gender_male] protocol_definitions['mobile0-male'] = [clients_male, train_mobile, enroll_mobile, probe, gender_male]
protocol_definitions['mobile0-female'] = [clients_female, train_mobile, enroll_mobile, probe, gender_female] protocol_definitions['mobile0-female'] = [clients_female, train_mobile, enroll_mobile, probe, gender_female]
protocol_definitions['mobile1-male'] = [clients_male, train_all, enroll_mobile, probe, gender_male] protocol_definitions['mobile1-male'] = [clients_male, train_all, enroll_mobile, probe, gender_male]
...@@ -692,7 +695,7 @@ def add_protocols(session, verbose): ...@@ -692,7 +695,7 @@ def add_protocols(session, verbose):
protocol_definitions['laptop_mobile1-female'] = [clients_female, train_all, enroll_laptop_mobile, probe, gender_female] protocol_definitions['laptop_mobile1-female'] = [clients_female, train_all, enroll_laptop_mobile, probe, gender_female]
# 2. ADDITIONS TO THE SQL DATABASE # 2. ADDITIONS TO THE SQL DATABASE
protocolPurpose_list = [('world', 'train'), ('dev', 'enroll'), ('dev', 'probe'), ('eval', 'enroll'), ('eval', 'probe')] protocolPurpose_list = [('world', 'train'), ('dev', 'enroll'), ('dev', 'probe'), ('eval', 'enroll'), ('eval', 'probe')]
for proto in protocol_definitions: for proto in protocol_definitions:
p = Protocol(proto, protocol_definitions[proto][4]) p = Protocol(proto, protocol_definitions[proto][4])
# Add protocol # Add protocol
......
...@@ -176,7 +176,7 @@ class Protocol(Base): ...@@ -176,7 +176,7 @@ class Protocol(Base):
id = Column(Integer, primary_key=True) id = Column(Integer, primary_key=True)
# Name of the protocol associated with this object # Name of the protocol associated with this object
name = Column(String(20), unique=True) name = Column(String(20), unique=True)
gender_choices = ('female', 'male') gender_choices = ('female', 'male','both')
gender = Column(Enum(*gender_choices)) gender = Column(Enum(*gender_choices))
def __init__(self, name, gender): def __init__(self, name, gender):
......
...@@ -127,6 +127,7 @@ class Database(bob.db.base.SQLiteDatabase): ...@@ -127,6 +127,7 @@ class Database(bob.db.base.SQLiteDatabase):
groups, "group", self.groups(), self.groups()) groups, "group", self.groups(), self.groups())
subworld = self.check_parameters_for_validity( subworld = self.check_parameters_for_validity(
subworld, "subworld", self.subworld_names(), []) subworld, "subworld", self.subworld_names(), [])
gender = self.check_parameters_for_validity( gender = self.check_parameters_for_validity(
gender, "gender", self.genders(), []) gender, "gender", self.genders(), [])
...@@ -152,6 +153,8 @@ class Database(bob.db.base.SQLiteDatabase): ...@@ -152,6 +153,8 @@ class Database(bob.db.base.SQLiteDatabase):
if protocol: if protocol:
q = self.query(Protocol).filter(Protocol.name.in_(protocol)).one() q = self.query(Protocol).filter(Protocol.name.in_(protocol)).one()
protocol_gender = [q.gender] protocol_gender = [q.gender]
if "both" in protocol_gender:
protocol_gender = None
q = self.query(Client).filter(Client.sgroup.in_(dev_eval)) q = self.query(Client).filter(Client.sgroup.in_(dev_eval))
if protocol_gender: if protocol_gender:
q = q.filter(Client.gender.in_(protocol_gender)) q = q.filter(Client.gender.in_(protocol_gender))
......
...@@ -68,6 +68,7 @@ def test_clients(): ...@@ -68,6 +68,7 @@ def test_clients():
# Check T-Norm and Z-Norm clients # Check T-Norm and Z-Norm clients
assert len(db.tclients(protocol='mobile0-female')) == 16 assert len(db.tclients(protocol='mobile0-female')) == 16
assert len(db.tclients(protocol='mobile0-male')) == 16 assert len(db.tclients(protocol='mobile0-male')) == 16
assert len(db.tclients(protocol='mobile0-male-female')) == 16
assert len(db.tclients(protocol='mobile1-female')) == 16 assert len(db.tclients(protocol='mobile1-female')) == 16
assert len(db.tclients(protocol='mobile1-male')) == 16 assert len(db.tclients(protocol='mobile1-male')) == 16
assert len(db.tclients(protocol='laptop1-female')) == 16 assert len(db.tclients(protocol='laptop1-female')) == 16
...@@ -79,6 +80,7 @@ def test_clients(): ...@@ -79,6 +80,7 @@ def test_clients():
assert len(db.zclients()) == 16 assert len(db.zclients()) == 16
assert len(db.zclients(protocol='mobile0-female')) == 16 assert len(db.zclients(protocol='mobile0-female')) == 16
assert len(db.zclients(protocol='mobile0-male')) == 16 assert len(db.zclients(protocol='mobile0-male')) == 16
assert len(db.zclients(protocol='mobile0-male-female')) == 16
assert len(db.zclients(protocol='mobile1-female')) == 16 assert len(db.zclients(protocol='mobile1-female')) == 16
assert len(db.zclients(protocol='mobile1-male')) == 16 assert len(db.zclients(protocol='mobile1-male')) == 16
assert len(db.zclients(protocol='laptop1-female')) == 16 assert len(db.zclients(protocol='laptop1-female')) == 16
...@@ -90,6 +92,7 @@ def test_clients(): ...@@ -90,6 +92,7 @@ def test_clients():
# Check T-Norm models # Check T-Norm models
assert len(db.tmodels(protocol='mobile0-female')) == 192 assert len(db.tmodels(protocol='mobile0-female')) == 192
assert len(db.tmodels(protocol='mobile0-male')) == 192 assert len(db.tmodels(protocol='mobile0-male')) == 192
assert len(db.tmodels(protocol='mobile0-male-female')) == 192
assert len(db.tmodels(protocol='mobile1-female')) == 208 assert len(db.tmodels(protocol='mobile1-female')) == 208
assert len(db.tmodels(protocol='mobile1-male')) == 208 assert len(db.tmodels(protocol='mobile1-male')) == 208
assert len(db.tmodels(protocol='laptop1-female')) == 208 assert len(db.tmodels(protocol='laptop1-female')) == 208
...@@ -105,8 +108,8 @@ def test_protocols(): ...@@ -105,8 +108,8 @@ def test_protocols():
db = bob.db.mobio.Database() db = bob.db.mobio.Database()
assert len(db.protocols()) == 8 assert len(db.protocols()) == 9
assert len(db.protocol_names()) == 8 assert len(db.protocol_names()) == 9
assert db.has_protocol('mobile0-male') assert db.has_protocol('mobile0-male')
assert db.has_protocol('mobile0-female') assert db.has_protocol('mobile0-female')
assert db.has_protocol('mobile1-male') assert db.has_protocol('mobile1-male')
...@@ -117,6 +120,7 @@ def test_protocols(): ...@@ -117,6 +120,7 @@ def test_protocols():
assert db.has_protocol('laptop_mobile1-female') assert db.has_protocol('laptop_mobile1-female')
assert db.has_protocol('male') # alias to 'mobile0-male' assert db.has_protocol('male') # alias to 'mobile0-male'
assert db.has_protocol('female') # alias 'mobile0-female' assert db.has_protocol('female') # alias 'mobile0-female'
assert db.has_protocol('mobile0-male-female')
assert len(db.subworlds()) == 3 assert len(db.subworlds()) == 3
assert len(db.subworld_names()) == 3 assert len(db.subworld_names()) == 3
...@@ -179,6 +183,33 @@ def test_objects(): ...@@ -179,6 +183,33 @@ def test_objects():
assert len(db.objects(protocol='mobile0-male', groups='eval', purposes='probe', classes='impostor', model_ids=1)) == 3885 assert len(db.objects(protocol='mobile0-male', groups='eval', purposes='probe', classes='impostor', model_ids=1)) == 3885
# Protocol mobile0-male-female
# World group
assert len(db.objects(protocol='mobile0-male-female', groups='world')) == 9600
assert len(db.objects(protocol='mobile0-male-female', groups='world', purposes='train')) == 9600
assert len(db.objects(protocol='mobile0-male-female', groups='world', gender=['male','female'])) == 7104 + 2496
assert len(db.objects(protocol='mobile0-male-female', groups='world', purposes='train', model_ids=204)) == 192
# Dev group
assert len(db.objects(protocol='mobile0-male-female', groups='dev')) == 2640 + 1980
assert len(db.objects(protocol='mobile0-male-female', groups='dev', purposes='enroll')) == 120 + 90
assert len(db.objects(protocol='mobile0-male-female', groups='dev', purposes='probe')) == 2520 + 1890
assert len(db.objects(protocol='mobile0-male-female', groups='dev', purposes='probe', classes='client')) == 2520 + 1890
assert len(db.objects(protocol='mobile0-male-female', groups='dev', purposes='probe', classes='impostor')) == 2520 + 1890
assert len(db.objects(protocol='mobile0-male-female', groups='dev', purposes='probe', classes='client', model_ids=103)) == 105
assert len(db.objects(protocol='mobile0-male-female', groups='dev', purposes='probe', classes='impostor', model_ids=103)) == 4305
# Eval group
assert len(db.objects(protocol='mobile0-male-female', groups='eval')) == 4180 + 2200
assert len(db.objects(protocol='mobile0-male-female', groups='eval', purposes='enroll')) == 190 + 100
assert len(db.objects(protocol='mobile0-male-female', groups='eval', purposes='probe')) == 3990 + 2100
assert len(db.objects(protocol='mobile0-male-female', groups='eval', purposes='probe', classes='client')) == 3990 + 2100
assert len(db.objects(protocol='mobile0-male-female', groups='eval', purposes='probe', classes='impostor')) == 3990 + 2100
assert len(db.objects(protocol='mobile0-male-female', groups='eval', purposes='probe', classes='client', model_ids=1)) == 105
assert len(db.objects(protocol='mobile0-male-female', groups='eval', purposes='probe', classes='impostor', model_ids=1)) == 3885 + 1995 + 105
# Protocol mobile1-female # Protocol mobile1-female
# World group # World group
assert len(db.objects(protocol='mobile1-female', groups='world')) == 10650 assert len(db.objects(protocol='mobile1-female', groups='world')) == 10650
......
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