-
Notifications
You must be signed in to change notification settings - Fork 11
/
dli-show
executable file
·75 lines (63 loc) · 2 KB
/
dli-show
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/usr/bin/python3
from __future__ import print_function
import argparse
import imp
import time
import dlinputs as dli
import matplotlib
import numpy as np
import pylab
from dlinputs import gopen, utils, zcom
from pylab import *
# matplotlib.use("GTK")
rc("figure", figsize="12,6")
rc("image", cmap="gray")
parser = argparse.ArgumentParser("Display info about an input module.")
parser.add_argument("input", nargs="+")
parser.add_argument("-T", "--table", default="training")
parser.add_argument("-s", "--skip", default=0, type=int)
parser.add_argument("-b", "--bench", default=0, type=int)
parser.add_argument("-B", "--batched", action="store_true")
parser.add_argument("-d", "--display", default=None)
parser.add_argument("--decoders", default=None)
parser.add_argument("-O", "--order", default="BHWD")
parser.add_argument("-a", "--autodecode", action="store_true")
parser.add_argument("-D", "--source", default=None)
parser.add_argument("-t", "--timeout", default=-1, type=float)
args = parser.parse_args()
if args.source is not None:
execfile(args.source)
source = make_source()
else:
source = gopen.open_source(args.input[0])
for i in range(args.skip):
next(source)
sample = next(source)
utils.print_sample(sample)
if args.bench > 0:
print
start = time.time()
for i in range(args.bench):
next(source)
total = time.time() - start
print("sec/sample", total/args.bench)
if args.display is not None:
ion()
keys = args.display.split(",")
for i in range(1000):
utils.print_sample(sample)
clf()
for j,key in enumerate(keys):
subplot(1, len(keys), j+1)
data = sample[key]
if data.ndim==3 and data.shape[2]==1:
data = data[:,:,0]
if args.batched:
data = data[0]
gca().set_title("Key: "+key)
imshow(data)
show()
waitforbuttonpress(timeout=args.timeout)
if not fignum_exists(1):
sys.exit(0)
sample = next(source)