yiyixuxu commited on
Commit
8bee4af
1 Parent(s): 18683f1

testing aria2c

Browse files
Files changed (2) hide show
  1. app.py +7 -2
  2. packages.txt +2 -1
app.py CHANGED
@@ -16,6 +16,7 @@ import gradio as gr
16
  device = "cuda" if torch.cuda.is_available() else "cpu"
17
  model, preprocess = clip.load("ViT-B/32")
18
 
 
19
  def select_video_format(url, format_note='480p', ext='mp4'):
20
  defaults = ['480p', '360p','240p','144p']
21
  ydl_opts = {}
@@ -32,10 +33,14 @@ def select_video_format(url, format_note='480p', ext='mp4'):
32
  print(f'format selected: {format}')
33
  return(format, format_id, fps)
34
 
35
- # to-do: delete saved videos
 
 
36
  def download_video(url,format_id, n_keep=10):
37
  ydl_opts = {
38
  'format':format_id,
 
 
39
  'outtmpl': "videos/%(id)s.%(ext)s"}
40
  # create a directory for saved videos
41
  video_path = Path('videos')
@@ -122,7 +127,7 @@ def captioned_strip(images, caption=None, times=None, rows=1):
122
  (255, 255, 255), font=font_small)
123
  return img
124
 
125
- def run_inference(url, sampling_interval, search_query, bs=256):
126
  skip_frames, path_frames= vid2frames(url,sampling_interval)
127
  filenames = sorted(path_frames.glob('*.jpg'),key=lambda p: int(p.stem))
128
  n_frames = len(filenames)
 
16
  device = "cuda" if torch.cuda.is_available() else "cpu"
17
  model, preprocess = clip.load("ViT-B/32")
18
 
19
+
20
  def select_video_format(url, format_note='480p', ext='mp4'):
21
  defaults = ['480p', '360p','240p','144p']
22
  ydl_opts = {}
 
33
  print(f'format selected: {format}')
34
  return(format, format_id, fps)
35
 
36
+
37
+ # to-do: delete saved videos
38
+ # testing aria2c
39
  def download_video(url,format_id, n_keep=10):
40
  ydl_opts = {
41
  'format':format_id,
42
+ 'external_downloader' : 'aria2c',
43
+ 'external_downloader_args' :['--max-connection-per-server=16','--dir=videos'],
44
  'outtmpl': "videos/%(id)s.%(ext)s"}
45
  # create a directory for saved videos
46
  video_path = Path('videos')
 
127
  (255, 255, 255), font=font_small)
128
  return img
129
 
130
+ def run_inference(url, sampling_interval, search_query, bs=526):
131
  skip_frames, path_frames= vid2frames(url,sampling_interval)
132
  filenames = sorted(path_frames.glob('*.jpg'),key=lambda p: int(p.stem))
133
  n_frames = len(filenames)
packages.txt CHANGED
@@ -1,2 +1,3 @@
1
  ffmpeg
2
- fonts-liberation2
 
 
1
  ffmpeg
2
+ fonts-liberation2
3
+ aria2c