ysharma HF staff commited on
Commit
e37d735
1 Parent(s): 103e0de
Files changed (1) hide show
  1. app.py +6 -3
app.py CHANGED
@@ -8,6 +8,7 @@ import base64
8
  import requests
9
  import moviepy.editor as mp
10
  from PIL import Image, ImageSequence
 
11
 
12
 
13
  API_URL = "https://api-inference.huggingface.co/models/facebook/wav2vec2-base-960h"
@@ -70,13 +71,13 @@ def generate_gifs(gif_transcript, words, words_timestamp):
70
  start_seconds, end_seconds = get_gif_timestamps(giflist_indxs, words_timestamp)
71
  print(f"start_seconds, end_seconds are : ({start_seconds}, {end_seconds})")
72
  #generated .gif image
73
- im, gif_img, gif_vid = gen_moviepy_gif(start_seconds, end_seconds)
74
  im.save('./gifimage1.gif', save_all=True)
75
  #gif_img = gen_moviepy_gif(start_seconds, end_seconds)
76
  #gif_img = f"./gifimage.gif"
77
  #html_out = "<img src= '" + gif_img + "' alt='create a gif from video' width='100%'/>"
78
  #print("html out is :", html_out)
79
- return gif_vid
80
 
81
 
82
  #calling the hosted model
@@ -189,8 +190,10 @@ def gen_moviepy_gif(start_seconds, end_seconds):
189
  gif_vid = mp.VideoFileClip("gifimage.mp4")
190
 
191
  im = Image.open("gifimage.gif")
 
 
192
  print("At the very end")
193
- return im, gif_img, gif_vid
194
 
195
 
196
  # showing gif
 
8
  import requests
9
  import moviepy.editor as mp
10
  from PIL import Image, ImageSequence
11
+ import cv2
12
 
13
 
14
  API_URL = "https://api-inference.huggingface.co/models/facebook/wav2vec2-base-960h"
 
71
  start_seconds, end_seconds = get_gif_timestamps(giflist_indxs, words_timestamp)
72
  print(f"start_seconds, end_seconds are : ({start_seconds}, {end_seconds})")
73
  #generated .gif image
74
+ im, gif_img, gif_vid, vid_cap = gen_moviepy_gif(start_seconds, end_seconds)
75
  im.save('./gifimage1.gif', save_all=True)
76
  #gif_img = gen_moviepy_gif(start_seconds, end_seconds)
77
  #gif_img = f"./gifimage.gif"
78
  #html_out = "<img src= '" + gif_img + "' alt='create a gif from video' width='100%'/>"
79
  #print("html out is :", html_out)
80
+ return vid_cap #gif_vid
81
 
82
 
83
  #calling the hosted model
 
190
  gif_vid = mp.VideoFileClip("gifimage.mp4")
191
 
192
  im = Image.open("gifimage.gif")
193
+ vid_cap = cv2.VideoCapture('gifimage.mp4')
194
+
195
  print("At the very end")
196
+ return im, gif_img, gif_vid, vid_cap
197
 
198
 
199
  # showing gif