diff --git a/applications/DAIN/predict.py b/applications/DAIN/predict.py index 3a8294e1e9f9a6f8d2be62c7f1258a81d37760b3..39290433b2b0cfbc2bfcce18d800740987c1d131 100644 --- a/applications/DAIN/predict.py +++ b/applications/DAIN/predict.py @@ -202,12 +202,6 @@ class VideoFrameInterp(object): X0 = img_first.astype('float32').transpose((2, 0, 1)) / 255 X1 = img_second.astype('float32').transpose((2, 0, 1)) / 255 - #if key_frame: - # y_ = [ - # np.transpose(255.0 * X0.clip(0, 1.0), (1, 2, 0)) - # for i in range(num_frames) - # ] - #else: assert (X0.shape[1] == X1.shape[1]) assert (X0.shape[2] == X1.shape[2]) diff --git a/applications/DAIN/util.py b/applications/DAIN/util.py index 2bd98e4915c5d95920322e9bcd778ad335ff36ff..dc343ff20668f0b9db3a426a3789943ea4e28cb5 100644 --- a/applications/DAIN/util.py +++ b/applications/DAIN/util.py @@ -48,24 +48,24 @@ def combine_frames(input, interpolated, combined, num_frames): def remove_duplicates(paths): - def dhash(image, hashSize=8): + def dhash(image, hash_size=8): gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) - resized = cv2.resize(gray, (hashSize + 1, hashSize)) + resized = cv2.resize(gray, (hash_size + 1, hash_size)) diff = resized[:, 1:] > resized[:, :-1] return sum([2**i for (i, v) in enumerate(diff.flatten()) if v]) hashes = {} - imagePaths = sorted(glob.glob(os.path.join(paths, '*.png'))) - for imagePath in imagePaths: - image = cv2.imread(imagePath) + image_paths = sorted(glob.glob(os.path.join(paths, '*.png'))) + for image_path in image_paths: + image = cv2.imread(image_path) h = dhash(image) p = hashes.get(h, []) - p.append(imagePath) + p.append(image_path) hashes[h] = p - for (h, hashedPaths) in hashes.items(): - if len(hashedPaths) > 1: - for p in hashedPaths[1:]: + for (h, hashed_paths) in hashes.items(): + if len(hashed_paths) > 1: + for p in hashed_paths[1:]: os.remove(p) frames = sorted(glob.glob(os.path.join(paths, '*.png')))