sxela commited on
Commit
c038202
1 Parent(s): e4f999b

add precreated output array

Browse files
Files changed (1) hide show
  1. app.py +6 -2
app.py CHANGED
@@ -122,6 +122,7 @@ def inference_step(vid, start_sec, duration, out_fps, interpolate):
122
 
123
  def predict_fn(filepath, start_sec, duration, out_fps, interpolate):
124
  # out_fps=12
 
125
  vid = EncodedVideo.from_path(filepath)
126
  for i in range(duration):
127
  video, audio, fps, audio_fps = inference_step(
@@ -133,10 +134,13 @@ def predict_fn(filepath, start_sec, duration, out_fps, interpolate):
133
  )
134
  gc.collect()
135
  if i == 0:
136
- video_all = video
 
 
137
  audio_all = audio
138
  else:
139
- video_all = np.concatenate((video_all, video))
 
140
  audio_all = np.hstack((audio_all, audio))
141
 
142
  write_video(
 
122
 
123
  def predict_fn(filepath, start_sec, duration, out_fps, interpolate):
124
  # out_fps=12
125
+ gc.collect()
126
  vid = EncodedVideo.from_path(filepath)
127
  for i in range(duration):
128
  video, audio, fps, audio_fps = inference_step(
 
134
  )
135
  gc.collect()
136
  if i == 0:
137
+ #video_all = video
138
+ video_all = np.zeros((duration*out_fps, *video.shape[1:])).astype('uint8')
139
+ video_all[i*out_fps:(i+1)*out_fps,...] = video.astype('uint8')
140
  audio_all = audio
141
  else:
142
+ #video_all = np.concatenate((video_all, video))
143
+ video_all[i*out_fps:(i+1)*out_fps,...] = video.astype('uint8')
144
  audio_all = np.hstack((audio_all, audio))
145
 
146
  write_video(