fffiloni commited on
Commit
b05a641
1 Parent(s): cb85dca

set max length to 3 seconds and max fps to 24 to fit model limitations

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -106,16 +106,16 @@ def get_frames(video_in, img_type):
106
  # Cut the video to the first 5 seconds
107
  video_out = f"{img_type}_video_cut.mp4"
108
 
109
- ffmpeg_extract_subclip(video_in, t1=0, t2=5, targetname=video_out)
110
  # Now, proceed with resizing the cut video
111
  clip = VideoFileClip(video_out)
112
 
113
  #check fps
114
 
115
- if clip.fps > 30:
116
- print("vide rate is over 30, resetting to 30")
117
  clip_resized = clip.resize(height=512)
118
- clip_resized.write_videofile(f"{img_type}_video_resized.mp4", fps=30)
119
  else:
120
  print("video rate is OK")
121
  clip_resized = clip.resize(height=512)
@@ -154,7 +154,7 @@ def get_matte(video_in, subject_to_remove):
154
  print("Trying to call video matting")
155
  result = matte_client.predict(
156
  f"{video_in}", # str (filepath on your computer (or URL) of file) in 'parameter_4' Video component
157
- 5, # int | float (numeric value between 0 and 10) in 'Cut video at (s)' Slider component
158
  f"{subject_to_remove}", # str in 'Text prompt' Textbox component
159
  "", # str in 'Background prompt' Textbox component
160
  api_name="/go_matte"
 
106
  # Cut the video to the first 5 seconds
107
  video_out = f"{img_type}_video_cut.mp4"
108
 
109
+ ffmpeg_extract_subclip(video_in, t1=0, t2=3, targetname=video_out)
110
  # Now, proceed with resizing the cut video
111
  clip = VideoFileClip(video_out)
112
 
113
  #check fps
114
 
115
+ if clip.fps > 24:
116
+ print("vide rate is over 24, resetting to 24")
117
  clip_resized = clip.resize(height=512)
118
+ clip_resized.write_videofile(f"{img_type}_video_resized.mp4", fps=24)
119
  else:
120
  print("video rate is OK")
121
  clip_resized = clip.resize(height=512)
 
154
  print("Trying to call video matting")
155
  result = matte_client.predict(
156
  f"{video_in}", # str (filepath on your computer (or URL) of file) in 'parameter_4' Video component
157
+ 3, # int | float (numeric value between 0 and 10) in 'Cut video at (s)' Slider component
158
  f"{subject_to_remove}", # str in 'Text prompt' Textbox component
159
  "", # str in 'Background prompt' Textbox component
160
  api_name="/go_matte"