-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathscript_run_targeted.py
More file actions
43 lines (31 loc) · 1.2 KB
/
script_run_targeted.py
File metadata and controls
43 lines (31 loc) · 1.2 KB
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
import os
import numpy as np
import glob
import time
import sys
# you can change the gpuID as your device
gpuID = 0
# load the list of selected images
# (We selected these images from the dev set of MSCOCO. You need to change the path list according to your local paths.)
imgs = np.load('./selected_images.npy')
i = 0
start = time.time()
CONFIDENT = int(sys.argv[1])
for img in imgs:
path, fileName = os.path.split(img)
fileName_main = fileName.replace('.jpg','')
# if fileName_main in open('results.txt').read():
# continue
# TODO: need if-else for confident/frequent
for r in range(10):
random_class = np.random.randint(1599)+1
file_output = fileName_main+'_'+str(random_class) +'.npy'
if CONFIDENT:
os.system('python ./code/pickobject_confident.py ' + img + ' ' + str(10000) + ' ' + 'True' +
' ' + str(random_class) + ' ' + file_output + ' ' + str(gpuID))
else:
os.system('python ./code/pickobject_frequent.py '+ img +' '+ str(10000) + ' ' + 'True'+
' ' + str(random_class) + ' ' + file_output + ' ' + str(gpuID))
i = i+1
end = time.time()
print 'total time: ', end - start