summaryrefslogtreecommitdiff
path: root/megapixels/commands/datasets/lookup.py
blob: 11f549577014bc53c236ac8f97d33774f19bebd7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import click

from app.settings import types
from app.utils import click_utils
from app.settings import app_cfg as cfg
from app.utils.logger_utils import Logger

log = Logger.getLogger()

lookup_types = ['image', 'identity']

@click.command()
@click.option('-i', '--input', 'opt_fp_in', required=True,
  help='Input CSV file')
@click.option('-t', '--type', 'opt_type', default='image', 
  type=click.Choice(lookup_types),
  help='Type of lookup')
@click.option('-d', '--dataset', 'opt_dataset', required=True,
  type=cfg.DatasetVar,
  default=click_utils.get_default(types.Dataset.LFW),
  show_default=True,
  help=click_utils.show_help(types.Dataset))
@click.option('--index', 'opt_index', required=True,
  help='Index to lookup')
@click.pass_context
def cli(ctx, opt_fp_in, opt_fp_out, opt_index):
  """Display image info"""
  
  from glob import glob
  from os.path import join
  from pathlib import Path
  import time

  import pandas as pd
  from tqdm import tqdm
  
  from app.utils import file_utils, im_utils

  # lookup and index and display all information
  df = pd.read_csv(opt_fp_in).set_index('index')