Skip to content

Commit

Permalink
add '--write_json' option to facenet_pytorch
Browse files Browse the repository at this point in the history
  • Loading branch information
ohshima-axell committed Apr 11, 2024
1 parent 2e96e58 commit cba8abb
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions face_identification/facenet_pytorch/facenet_pytorch.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import sys
import time
from logging import getLogger
import json

import ailia
import cv2
Expand Down Expand Up @@ -32,6 +33,11 @@
choices=['vggface2', 'casia-webface'],
help='You can choose the model weights.'
)
parser.add_argument(
'--write_json',
action='store_true',
help='Flag to output results to json file.'
)
args = update_parser(parser)


Expand Down Expand Up @@ -131,6 +137,14 @@ def main():
np.set_printoptions(linewidth=1000)
logger.info('Similarity: \n' + np.array2string(attach_label(sim_matrix, filenames)))

if args.write_json:
result = attach_label(sim_matrix, filenames)
out_data = []
for r in result:
out_data.append(tuple(r))
with open('output.json', 'w', encoding='utf-8') as f:
json.dump(out_data, f, indent=2)

if __name__ == '__main__':
main()

0 comments on commit cba8abb

Please sign in to comment.