jbilcke-hf HF staff commited on
Commit
28cbc54
1 Parent(s): 3d92ac3

Update handler.py

Browse files
Files changed (1) hide show
  1. handler.py +10 -11
handler.py CHANGED
@@ -273,18 +273,17 @@ class EndpointHandler:
273
  raise ValueError(f"Expected tensor of shape [frames, channels, height, width], got shape {frames.shape}")
274
 
275
  # Post-process frames
276
-
277
- loop = asyncio.new_event_loop()
278
-
279
  try:
280
- video_uri, metadata = loop.run_until_complete(
281
- self.process_frames(frames, config)
282
- )
283
- except Exception as e:
284
- raise RuntimeError(f"Failed to convert the frames to a video, because {str(e)}")
285
- finally:
286
- loop.close()
287
-
 
288
  return {
289
  "video": video_uri,
290
  "content-type": "video/mp4",
 
273
  raise ValueError(f"Expected tensor of shape [frames, channels, height, width], got shape {frames.shape}")
274
 
275
  # Post-process frames
276
+
 
 
277
  try:
278
+ loop = asyncio.get_event_loop()
279
+ except RuntimeError:
280
+ loop = asyncio.new_event_loop()
281
+ asyncio.set_event_loop(loop)
282
+
283
+ video_uri, metadata = loop.run_until_complete(
284
+ self.process_frames(frames, config)
285
+ )
286
+
287
  return {
288
  "video": video_uri,
289
  "content-type": "video/mp4",