chongzhou commited on
Commit
4277d6f
·
1 Parent(s): 7af8abe

change to decorator

Browse files
Files changed (1) hide show
  1. app.py +4 -10
app.py CHANGED
@@ -26,6 +26,7 @@ import tempfile
26
  import cv2
27
  import matplotlib.pyplot as plt
28
  import numpy as np
 
29
 
30
  import torch
31
 
@@ -174,6 +175,7 @@ def clear_points(
174
  )
175
 
176
 
 
177
  def preprocess_video_in(
178
  video_path,
179
  first_frame,
@@ -258,6 +260,7 @@ def preprocess_video_in(
258
  ]
259
 
260
 
 
261
  def segment_with_points(
262
  point_type,
263
  first_frame,
@@ -350,6 +353,7 @@ def show_mask(mask, obj_id=None, random_color=False, convert_to_image=True):
350
  return mask
351
 
352
 
 
353
  def propagate_to_all(
354
  video_in,
355
  first_frame,
@@ -418,16 +422,6 @@ def propagate_to_all(
418
  )
419
 
420
 
421
- try:
422
- from spaces import GPU
423
-
424
- preprocess_video_in = GPU(preprocess_video_in, duration=10)
425
- segment_with_points = GPU(segment_with_points, duration=5)
426
- propagate_to_all = GPU(propagate_to_all, duration=30)
427
- except:
428
- print("spaces unavailable")
429
-
430
-
431
  def update_ui():
432
  return gr.update(visible=True)
433
 
 
26
  import cv2
27
  import matplotlib.pyplot as plt
28
  import numpy as np
29
+ import spaces
30
 
31
  import torch
32
 
 
175
  )
176
 
177
 
178
+ @spaces.GPU(duration=10)
179
  def preprocess_video_in(
180
  video_path,
181
  first_frame,
 
260
  ]
261
 
262
 
263
+ @spaces.GPU(duration=5)
264
  def segment_with_points(
265
  point_type,
266
  first_frame,
 
353
  return mask
354
 
355
 
356
+ @spaces.GPU(duration=30)
357
  def propagate_to_all(
358
  video_in,
359
  first_frame,
 
422
  )
423
 
424
 
 
 
 
 
 
 
 
 
 
 
425
  def update_ui():
426
  return gr.update(visible=True)
427