diff options
| author | adamhrv <adam@ahprojects.com> | 2018-12-13 14:39:07 +0100 |
|---|---|---|
| committer | adamhrv <adam@ahprojects.com> | 2018-12-13 14:39:07 +0100 |
| commit | bd51b3cdf474c93b1d7c667d9e5a33159c97640a (patch) | |
| tree | 6a5ae5524efa971cbd348cc2720d200fbeb2fecb /megapixels/commands/datasets/vecs_to_uuid.py | |
| parent | 49a49bebe3f972e93add837180f5672a4ae62ce0 (diff) | |
add pose, indexing
Diffstat (limited to 'megapixels/commands/datasets/vecs_to_uuid.py')
| -rw-r--r-- | megapixels/commands/datasets/vecs_to_uuid.py | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/megapixels/commands/datasets/vecs_to_uuid.py b/megapixels/commands/datasets/vecs_to_uuid.py new file mode 100644 index 00000000..7bb82083 --- /dev/null +++ b/megapixels/commands/datasets/vecs_to_uuid.py @@ -0,0 +1,56 @@ +""" +Crop images to prepare for training +""" + +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 UUID 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 + uuid_vecs = {} + + for roi_idx, row in tqdm(df_vecs.iterrows(), total=nrows): + # make image path + record_id = int(row['id']) + uuid = df_records.iloc[record_id]['uuid'] + vec = row['vec'].split(',') + uuid_vecs[uuid] = vec + + # save as JSON + file_utils.write_json(uuid_vecs, opt_fp_out) + +
\ No newline at end of file |
