mfarre HF staff commited on
Commit
1167d4f
·
1 Parent(s): 4c7362f

initial test

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -9,6 +9,7 @@ import torch
9
  from pathlib import Path
10
  import time
11
  import torch
 
12
 
13
 
14
  from video_highlight_detector import (
@@ -37,6 +38,7 @@ def add_watermark(video_path: str, output_path: str):
37
  -codec:a copy {output_path}"""
38
  os.system(command)
39
 
 
40
  def process_video(
41
  video_path: str,
42
  progress = gr.Progress()
@@ -162,10 +164,8 @@ def create_ui(examples_path: str):
162
 
163
  if __name__ == "__main__":
164
  # Initialize CUDA
165
- if not torch.cuda.is_available():
166
- raise RuntimeError("This application requires a GPU to run")
167
- torch.cuda.init()
168
- torch.cuda.empty_cache()
169
-
170
  app = create_ui("video_spec.json")
171
  app.launch()
 
9
  from pathlib import Path
10
  import time
11
  import torch
12
+ import spaces
13
 
14
 
15
  from video_highlight_detector import (
 
38
  -codec:a copy {output_path}"""
39
  os.system(command)
40
 
41
+ @spaces.GPU
42
  def process_video(
43
  video_path: str,
44
  progress = gr.Progress()
 
164
 
165
  if __name__ == "__main__":
166
  # Initialize CUDA
167
+ device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
168
+ zero = torch.Tensor([0]).to(device)
169
+
 
 
170
  app = create_ui("video_spec.json")
171
  app.launch()