forked from akirasosa/mobile-semantic-segmentation
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbench.py
More file actions
34 lines (23 loc) · 693 Bytes
/
bench.py
File metadata and controls
34 lines (23 loc) · 693 Bytes
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
import time
import numpy as np
from nets.MobileUNet import MobileUNet
img_size = 128
batch_num = 16
def main():
"""
Benchmark your model in your local pc.
"""
model = MobileUNet(input_shape=(img_size, img_size, 3))
inputs = np.random.randn(batch_num, img_size, img_size, 3)
time_per_batch = []
for i in range(10):
start = time.time()
model.predict(inputs, batch_size=batch_num)
elapsed = time.time() - start
time_per_batch.append(elapsed)
time_per_batch = np.array(time_per_batch)
# exclude 1st measure
print(time_per_batch[1:].mean())
print(time_per_batch[1:].std())
if __name__ == '__main__':
main()