Skip to content
Permalink
Browse files

fix(preprocessor): fix ffmpeg to deal with broken image

  • Loading branch information...
Larryjianfeng committed Jul 26, 2019
1 parent da77892 commit 7e43d5a295ae7b7217f2c32658d6c4c60fe285e1
Showing with 15 additions and 6 deletions.
  1. +15 −6 gnes/preprocessor/video/ffmpeg.py
@@ -89,18 +89,27 @@ def pic_weight(images: List['np.ndarray']) -> List[float]:

def duplicate_rm_hash(self,
images: List['np.ndarray']) -> List['np.ndarray']:
hash_list = [phash_descriptor(_) for _ in images]
hash_list = []
for _ in images:
try:
hash_list.append(phash_descriptor(_))
except Exception:
hash_list.append(False)
self.logger.info('Broken image: ignored !')
ret = []
for i, h in enumerate(hash_list):
flag = 1
if len(ret) >= 1:
# only keep images with high phash diff
# comparing only last kept 9 pics
for j in range(1, min(len(ret) + 1, 9)):
dist = abs(ret[-j][1] - h)
if dist < self.phash_thresh:
flag = 0
break
if h:
for j in range(1, min(len(ret) + 1, 9)):
dist = abs(ret[-j][1] - h)
if dist < self.phash_thresh:
flag = 0
break
else:
flag = 0
if flag:
ret.append((i, h))

0 comments on commit 7e43d5a

Please sign in to comment.
You can’t perform that action at this time.