diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2018-12-13 18:13:55 +0100 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2018-12-13 18:13:55 +0100 |
| commit | 3ab28a3ff3d0e1b71f123e38ce3d0df42caddc7c (patch) | |
| tree | 5ec327f62304c93583d982d20e2e92e7d0fa6f57 /megapixels/commands/datasets/vecs_to_id.py | |
| parent | d1da6ed6b0a6911c3b24e012ea051c9253ce8479 (diff) | |
| parent | bd51b3cdf474c93b1d7c667d9e5a33159c97640a (diff) | |
Merge branch 'master' of github.com:adamhrv/megapixels_dev
Diffstat (limited to 'megapixels/commands/datasets/vecs_to_id.py')
| -rw-r--r-- | megapixels/commands/datasets/vecs_to_id.py | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/megapixels/commands/datasets/vecs_to_id.py b/megapixels/commands/datasets/vecs_to_id.py new file mode 100644 index 00000000..07c7389e --- /dev/null +++ b/megapixels/commands/datasets/vecs_to_id.py @@ -0,0 +1,50 @@ +import click + +from app.settings import types +from app.utils import click_utils +from app.settings import app_cfg as cfg + +@click.command() +@click.option('-i', '--input', 'opt_fp_in', required=True, + help='Input directory') +@click.option('-r', '--records', 'opt_fp_records', required=True, + help='Input directory') +@click.option('-o', '--output', 'opt_fp_out', required=True, + help='Output JSON') +@click.option('-f', '--force', 'opt_force', is_flag=True, + help='Force overwrite file') +@click.pass_context +def cli(ctx, opt_fp_in, opt_fp_records, opt_fp_out,opt_force): + """Merges ID with face vectors""" + + import sys + import os + from os.path import join + from pathlib import Path + + from tqdm import tqdm + import pandas as pd + + from app.utils import logger_utils, file_utils + + # ------------------------------------------------- + # init here + + log = logger_utils.Logger.getLogger() + + df_vecs = pd.read_csv(opt_fp_in) + df_records = pd.read_csv(opt_fp_records) + nrows = len(df_vecs) + + # face vecs + id_vecs = {} + + for roi_idx, row in tqdm(df_vecs.iterrows(), total=nrows): + record_id = int(row['id']) + vec = row['vec'].split(',') + id_vecs[record_id] = vec + + # save as JSON + file_utils.write_json(id_vecs, opt_fp_out, verbose=True) + +
\ No newline at end of file |
