paralym commited on
Commit
8f53390
1 Parent(s): eb138a3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -10
app.py CHANGED
@@ -224,11 +224,8 @@ def sample_frames(video_path, frame_count=32):
224
 
225
  for i in range(0, total_frames, frame_interval):
226
  frame = vr[i].asnumpy()
227
- frame_image = Image.fromarray(frame)
228
- buffered = io.BytesIO()
229
- frame_image.save(buffered, format="JPEG")
230
- frame_base64 = base64.b64encode(buffered.getvalue()).decode("utf-8")
231
- video_frames.append(frame_base64)
232
  if len(video_frames) >= frame_count:
233
  break
234
 
@@ -236,11 +233,8 @@ def sample_frames(video_path, frame_count=32):
236
  if len(video_frames) < frame_count and total_frames > 0:
237
  for i in range(total_frames):
238
  frame = vr[i].asnumpy()
239
- frame_image = Image.fromarray(frame)
240
- buffered = io.BytesIO()
241
- frame_image.save(buffered, format="JPEG")
242
- frame_base64 = base64.b64encode(buffered.getvalue()).decode("utf-8")
243
- video_frames.append(frame_base64)
244
  if len(video_frames) >= frame_count:
245
  break
246
 
 
224
 
225
  for i in range(0, total_frames, frame_interval):
226
  frame = vr[i].asnumpy()
227
+ frame_image = Image.fromarray(frame) # Convert to PIL.Image
228
+ video_frames.append(frame_image)
 
 
 
229
  if len(video_frames) >= frame_count:
230
  break
231
 
 
233
  if len(video_frames) < frame_count and total_frames > 0:
234
  for i in range(total_frames):
235
  frame = vr[i].asnumpy()
236
+ frame_image = Image.fromarray(frame) # Convert to PIL.Image
237
+ video_frames.append(frame_image)
 
 
 
238
  if len(video_frames) >= frame_count:
239
  break
240