Skip to content

Commit

Permalink
Lock resolution of preview to 640p
Browse files Browse the repository at this point in the history
  • Loading branch information
henryruhs committed Aug 14, 2023
1 parent 9ebdcca commit 80b34f5
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions roop/uis/__components__/preview.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ def extract_preview_frame(temp_frame: Frame) -> Frame:
if predict_frame(temp_frame):
destroy()
source_face = get_one_face(cv2.imread(roop.globals.source_path)) if roop.globals.source_path else None
temp_frame = reduce_preview_frame(temp_frame)
if 'reference' in roop.globals.face_recognition and not get_face_reference():
reference_frame = get_video_frame(roop.globals.target_path, roop.globals.reference_frame_number)
reference_face = get_one_face(reference_frame, roop.globals.reference_face_position)
Expand All @@ -109,3 +110,10 @@ def extract_preview_frame(temp_frame: Frame) -> Frame:
return temp_frame


def reduce_preview_frame(temp_frame: Frame, max_height: int = 640) -> Frame:
height, width = temp_frame.shape[:2]
if height > max_height:
scale = max_height / height
max_width = int(width * scale)
temp_frame = cv2.resize(temp_frame, (max_width, max_height))
return temp_frame

0 comments on commit 80b34f5

Please sign in to comment.