profaker commited on
Commit
308210c
·
verified ·
1 Parent(s): 0b87669

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -6
app.py CHANGED
@@ -23,7 +23,7 @@ def video_to_frames(video_path, output_folder):
23
  cv2.imwrite(frame_name, image)
24
  success, image = vidcap.read()
25
  count += 1
26
- if count>500:
27
  break
28
  print(f"{count} frames extracted from {video_path}.")
29
  return [count,fps]
@@ -68,8 +68,7 @@ def frames_to_video(frame_folder, video_path, image_path, frame_count,fps):
68
  else:
69
  out.write(img1)
70
  progress = int((i + 1) / frame_count * 100)
71
- if progress%5==0 or progress%4==0:
72
- print(progress,end="")
73
  out.release()
74
 
75
  print(f"Video saved at {video_path}.")
@@ -77,8 +76,8 @@ def frames_to_video(frame_folder, video_path, image_path, frame_count,fps):
77
  def face_swap(video_path, image_path):
78
  output_folder = "Out_Frames"
79
  frame_count = video_to_frames(video_path, output_folder)
80
- if frame_count[0] > 150:
81
- frame_count[0] = 150
82
  output_video_path = "output_video.mp4"
83
  frames_to_video(output_folder, output_video_path, image_path, frame_count[0],frame_count[1])
84
  return output_video_path
@@ -88,7 +87,7 @@ iface = gr.Interface(
88
  fn=face_swap,
89
  inputs=["video", "image"],
90
  outputs="video",
91
- title="Face Swap",
92
  description="Upload a video and an image. The faces in the video will be swapped with the face in the image.",
93
  )
94
  iface.launch(share=True)
 
23
  cv2.imwrite(frame_name, image)
24
  success, image = vidcap.read()
25
  count += 1
26
+ if count>550:
27
  break
28
  print(f"{count} frames extracted from {video_path}.")
29
  return [count,fps]
 
68
  else:
69
  out.write(img1)
70
  progress = int((i + 1) / frame_count * 100)
71
+ print(progress,end="")
 
72
  out.release()
73
 
74
  print(f"Video saved at {video_path}.")
 
76
  def face_swap(video_path, image_path):
77
  output_folder = "Out_Frames"
78
  frame_count = video_to_frames(video_path, output_folder)
79
+ if frame_count[0] > 500:
80
+ frame_count[0] = 500
81
  output_video_path = "output_video.mp4"
82
  frames_to_video(output_folder, output_video_path, image_path, frame_count[0],frame_count[1])
83
  return output_video_path
 
87
  fn=face_swap,
88
  inputs=["video", "image"],
89
  outputs="video",
90
+ title="Profaker's Face Swap",
91
  description="Upload a video and an image. The faces in the video will be swapped with the face in the image.",
92
  )
93
  iface.launch(share=True)