Candle commited on
Commit ·
57d6cb5
1
Parent(s): 41efcac
stuff
Browse files- detect_loops.py +3 -8
detect_loops.py
CHANGED
|
@@ -16,8 +16,6 @@ def extract_frames(webp_path):
|
|
| 16 |
pass
|
| 17 |
return frames
|
| 18 |
|
| 19 |
-
|
| 20 |
-
|
| 21 |
def compute_sim(f1, f2):
|
| 22 |
# f1 and f2 are already grayscale and downscaled
|
| 23 |
mse = np.mean((f1.astype(np.float32) - f2.astype(np.float32)) ** 2)
|
|
@@ -47,12 +45,9 @@ def detect_loops(frames, min_len=6, max_len=40, top_k=3):
|
|
| 47 |
for i in range(n):
|
| 48 |
for j in range(i+min_len, min(i+max_len, n)):
|
| 49 |
t0 = time.time()
|
| 50 |
-
#
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
start_comp = np.mean([composite_frames[idx].astype(np.float32) for idx in start_idxs], axis=0)
|
| 54 |
-
end_comp = np.mean([composite_frames[idx].astype(np.float32) for idx in end_idxs], axis=0)
|
| 55 |
-
# No uint8 conversion; keep float32 for MSE
|
| 56 |
sim = compute_sim(start_comp, end_comp)
|
| 57 |
t1 = time.time()
|
| 58 |
score = -sim # Lower MSE is better, so negate for sorting
|
|
|
|
| 16 |
pass
|
| 17 |
return frames
|
| 18 |
|
|
|
|
|
|
|
| 19 |
def compute_sim(f1, f2):
|
| 20 |
# f1 and f2 are already grayscale and downscaled
|
| 21 |
mse = np.mean((f1.astype(np.float32) - f2.astype(np.float32)) ** 2)
|
|
|
|
| 45 |
for i in range(n):
|
| 46 |
for j in range(i+min_len, min(i+max_len, n)):
|
| 47 |
t0 = time.time()
|
| 48 |
+
# Compare composite frames directly
|
| 49 |
+
start_comp = composite_frames[i].astype(np.float32)
|
| 50 |
+
end_comp = composite_frames[j].astype(np.float32)
|
|
|
|
|
|
|
|
|
|
| 51 |
sim = compute_sim(start_comp, end_comp)
|
| 52 |
t1 = time.time()
|
| 53 |
score = -sim # Lower MSE is better, so negate for sorting
|