amirgame197 commited on
Commit
5066517
1 Parent(s): 7ba86ec

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -5
app.py CHANGED
@@ -7,10 +7,12 @@ import time
7
  from PIL import Image
8
  from transparent_background import Remover
9
 
10
- remover = Remover(mode='fast')
11
-
12
  @spaces.GPU
13
- def doo(video):
 
 
 
 
14
  cap = cv2.VideoCapture(video)
15
  fps = cap.get(cv2.CAP_PROP_FPS)
16
 
@@ -26,7 +28,7 @@ def doo(video):
26
  if ret is False:
27
  break
28
 
29
- if time.time() - start_time >= 6:
30
  print("GPU Timeout is coming")
31
  cap.release()
32
  writer.release()
@@ -46,5 +48,6 @@ def doo(video):
46
  writer.release()
47
  return 'output.mp4'
48
 
49
- iface = gr.Interface(fn=doo, inputs="video", outputs="video")
 
50
  iface.launch()
 
7
  from PIL import Image
8
  from transparent_background import Remover
9
 
 
 
10
  @spaces.GPU
11
+ def doo(video, mode):
12
+ if(mode == 'Normal'):
13
+ remover = Remover()
14
+ if(mode == 'Fast'):
15
+ remover = Remover(mode='fast')
16
  cap = cv2.VideoCapture(video)
17
  fps = cap.get(cv2.CAP_PROP_FPS)
18
 
 
28
  if ret is False:
29
  break
30
 
31
+ if time.time() - start_time >= 55:
32
  print("GPU Timeout is coming")
33
  cap.release()
34
  writer.release()
 
48
  writer.release()
49
  return 'output.mp4'
50
 
51
+ iface = gr.Interface(fn=doo, [gr.inputs.Video(type='filepath'),
52
+ gr.inputs.Radio(['Normal','Fast'], type="value", default='Fast', label='Select mode')], outputs="video")
53
  iface.launch()