-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from Gradiant/development
Development
- Loading branch information
Showing
80 changed files
with
330,976 additions
and
5 deletions.
There are no files selected for viewing
57 changes: 57 additions & 0 deletions
57
bob/paper/icb2019/gradgpad/scripts/generate_grad_gpad_protocols_text_lists.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#!/usr/bin/env python | ||
# Gradiant's Biometrics Team <[email protected]> | ||
# Copyright (C) 2017 Gradiant, Vigo, Spain | ||
|
||
import argparse | ||
import os | ||
|
||
from bob.gradiant.face.databases import AggregateDatabase, get_database_from_key, export_database_paths_from_file | ||
|
||
|
||
def has_args(args): | ||
is_active = False | ||
for arg in vars(args): | ||
is_active = is_active or getattr(args, arg) | ||
return is_active | ||
|
||
|
||
def write_dict_to_file(filename, d): | ||
with open(filename, 'w') as f: | ||
for k in d.keys(): | ||
f.write('{}\n'.format(k)) | ||
|
||
|
||
def main(): | ||
parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) | ||
parser.add_argument('--json-file', | ||
type=str, | ||
dest='json_file', | ||
help='json file where the ROOT_PATH of each dataset is defined', required=True) | ||
|
||
args = parser.parse_args() | ||
|
||
if not has_args(args): | ||
parser.print_help() | ||
else: | ||
|
||
base_output_path = 'gradgpad_protocols' | ||
os.makedirs(base_output_path, exist_ok=True) | ||
|
||
export_database_paths_from_file(args.json_file) # temporary | ||
aggregate_database = get_database_from_key('aggregate-database') # returns an object of AggregateDatabase class | ||
|
||
available_protocols = list(AggregateDatabase.get_available_protocols().keys()) | ||
|
||
for protocol in available_protocols: | ||
|
||
protocol_output_path = '{}/{}'.format(base_output_path, protocol) | ||
os.makedirs(protocol_output_path, exist_ok=True) | ||
|
||
content = aggregate_database.get_ground_truth_list(protocol) | ||
for subset, accesses in content.items(): | ||
filename = '{}/protocol_{}_{}.txt'.format(protocol_output_path, protocol, subset.lower()) | ||
write_dict_to_file(filename, accesses) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.