diff options
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 |
