-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathT2I.py
37 lines (28 loc) · 984 Bytes
/
T2I.py
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
import argparse
from sys import version_info
from os import system
import numpy as np
from showImages import show
from loadFeatures import Features
user_input = input if version_info[0] > 2 else raw_input
def load(name):
print("Loading %s ..." % (name))
cca = np.load(name, encoding='latin1', allow_pickle=True).item()
features = Features('features', 'train2017')
cca.loadFeatures(features)
return cca
def main(cca):
search = ''
while(search != 'EXIT'):
system("clear")
search = user_input("Search Terms: ")
res_IDs, similarities = cca.textToImageSearch(search, 5)
print(similarities)
show(res_IDs.tolist())
if __name__ == '__main__':
parser = argparse.ArgumentParser(description="Search image with tags in COCO")
parser.add_argument('--name', type=str, default='CCA_0.npy',
help='Filename for the cca')
args = parser.parse_args()
cca = load(args.name)
main(cca)