Spaces:
Configuration error
Configuration error
englert
commited on
Commit
·
c070174
1
Parent(s):
e52fc81
update app.py # 3
Browse files
app.py
CHANGED
@@ -37,29 +37,32 @@ def predict(input_file, downsample_size):
|
|
37 |
mean = np.asarray([0.3156024, 0.33569682, 0.34337464], dtype=np.float32)
|
38 |
std = np.asarray([0.16568947, 0.17827448, 0.18925823], dtype=np.float32)
|
39 |
|
40 |
-
img_vecs = []
|
41 |
-
with torch.no_grad():
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
img_vecs = np.asarray(img_vecs)
|
55 |
-
print("images encoded")
|
56 |
-
rv_indices, _ = furthest_neighbours(
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
indices = np.zeros((img_vecs.shape[0],))
|
61 |
-
indices[np.asarray(rv_indices)] = 1
|
62 |
-
print("images selected")
|
|
|
|
|
|
|
63 |
|
64 |
global_ctr = 0
|
65 |
for fp_i, file_path in enumerate([input_file]):
|
|
|
37 |
mean = np.asarray([0.3156024, 0.33569682, 0.34337464], dtype=np.float32)
|
38 |
std = np.asarray([0.16568947, 0.17827448, 0.18925823], dtype=np.float32)
|
39 |
|
40 |
+
# img_vecs = []
|
41 |
+
# with torch.no_grad():
|
42 |
+
# for fp_i, file_path in enumerate([input_file]):
|
43 |
+
# for i, in_img in enumerate(video_reader(file_path,
|
44 |
+
# targetFPS=9,
|
45 |
+
# targetWidth=100,
|
46 |
+
# to_rgb=True)):
|
47 |
+
# in_img = (in_img.astype(np.float32) / 255.)
|
48 |
+
# in_img = (in_img - mean) / std
|
49 |
+
# in_img = np.expand_dims(in_img, 0)
|
50 |
+
# in_img = np.transpose(in_img, (0, 3, 1, 2))
|
51 |
+
# in_img = torch.from_numpy(in_img).float()
|
52 |
+
# encoded = avg_pool(model(in_img))[0, :, 0, 0].cpu().numpy()
|
53 |
+
# img_vecs += [encoded]
|
54 |
+
# img_vecs = np.asarray(img_vecs)
|
55 |
+
# print("images encoded")
|
56 |
+
# rv_indices, _ = furthest_neighbours(
|
57 |
+
# x=img_vecs,
|
58 |
+
# downsample_size=downsample_size,
|
59 |
+
# seed=0)
|
60 |
+
# indices = np.zeros((img_vecs.shape[0],))
|
61 |
+
# indices[np.asarray(rv_indices)] = 1
|
62 |
+
# print("images selected")
|
63 |
+
|
64 |
+
indices = [0] * 1000
|
65 |
+
indices[0] = 1
|
66 |
|
67 |
global_ctr = 0
|
68 |
for fp_i, file_path in enumerate([input_file]):
|