MCPcopy
hub / github.com/Rudrabha/Wav2Lip / rescale_frames

Function rescale_frames

evaluation/real_videos_inference.py:51–70  ·  view source on GitHub ↗
(images)

Source from the content-addressed store, hash-verified

49 return boxes
50
51def rescale_frames(images):
52 rect = detector.get_detections_for_batch(np.array([images[0]]))[0]
53 if rect is None:
54 raise ValueError('Face not detected!')
55 h, w = images[0].shape[:-1]
56
57 x1, y1, x2, y2 = rect
58
59 face_size = max(np.abs(y1 - y2), np.abs(x1 - x2))
60
61 diff = np.abs(face_size - args.face_res)
62 for factor in range(2, 16):
63 downsampled_res = face_size // factor
64 if min(h//factor, w//factor) < args.min_frame_res: break
65 if np.abs(downsampled_res - args.face_res) >= diff: break
66
67 factor -= 1
68 if factor == 1: return images
69
70 return [cv2.resize(im, (im.shape[1]//(factor), im.shape[0]//(factor))) for im in images]
71
72
73def face_detect(images):

Callers 1

face_detectFunction · 0.85

Calls 1

Tested by

no test coverage detected