forked from google-deepmind/kinetics-i3d
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsandbox.py
41 lines (33 loc) · 952 Bytes
/
sandbox.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
38
39
40
41
import numpy as np
import scipy.ndimage as nd
import time
# X = np.random.rand(25, 224, 224, 3)
# X = nd.zoom(X, (1, 1.2, 1.2, 1))
# print(X.shape)
def crop_center(img, cropx, cropy):
y, x, channels = img.shape
startx = x//2-(cropx//2)
starty = y//2-(cropy//2)
return img[starty:starty+cropy, startx:startx+cropx, :]
# X = crop_center(X, 224, 224)
# print(X.shape)
# start = time.time()
# X = np.random.rand(1, 25, 224, 224, 3)
# X = nd.zoom(X, (1, 1, 1.2, 1.2, 1))
# print(X.shape)
# finish = time.time()
# print("time for 5 d", finish-start)
start = time.time()
X = np.random.rand(224, 224, 3)
X = nd.zoom(X, (1.2, 1.2, 1))
print(X.shape)
print("time for 3 d", time.time() - start)
start = time.time()
X = np.random.rand(1, 25, 224, 224, 3)
for i in range(25):
Y = X[0][i]
Y = nd.zoom(Y, (1.2, 1.2, 1))
Y = crop_center(Y, 224, 224)
X[0][i] = Y
print("time for 25 frames 3d", time.time() - start)
print(X.shape)