amirgame197 commited on
Commit
85d769e
1 Parent(s): 6ec31fd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -3,6 +3,7 @@ import gradio as gr
3
  import cv2
4
  import numpy as np
5
  import time
 
6
 
7
  from PIL import Image
8
  from transparent_background import Remover
@@ -17,7 +18,7 @@ def doo(video, mode):
17
  fps = cap.get(cv2.CAP_PROP_FPS)
18
 
19
  writer = None
20
-
21
  processed_frames = 0
22
  start_time = time.time()
23
 
@@ -31,12 +32,12 @@ def doo(video, mode):
31
  print("GPU Timeout is coming")
32
  cap.release()
33
  writer.release()
34
- return 'output.mp4'
35
  frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
36
  img = Image.fromarray(frame).convert('RGB')
37
 
38
  if writer is None:
39
- writer = cv2.VideoWriter('output.mp4', cv2.VideoWriter_fourcc(*'mp4v'), fps, img.size)
40
 
41
  processed_frames += 1
42
  print(f"Processing: {processed_frames}")
@@ -45,7 +46,7 @@ def doo(video, mode):
45
 
46
  cap.release()
47
  writer.release()
48
- return 'output.mp4'
49
 
50
  title = "🎞️Video Background Removal tool🎥"
51
 
 
3
  import cv2
4
  import numpy as np
5
  import time
6
+ import random
7
 
8
  from PIL import Image
9
  from transparent_background import Remover
 
18
  fps = cap.get(cv2.CAP_PROP_FPS)
19
 
20
  writer = None
21
+ tmpname = random.randint(111111111, 999999999)
22
  processed_frames = 0
23
  start_time = time.time()
24
 
 
32
  print("GPU Timeout is coming")
33
  cap.release()
34
  writer.release()
35
+ return tmpname + '.mp4'
36
  frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
37
  img = Image.fromarray(frame).convert('RGB')
38
 
39
  if writer is None:
40
+ writer = cv2.VideoWriter(tmpname + '.mp4', cv2.VideoWriter_fourcc(*'mp4v'), fps, img.size)
41
 
42
  processed_frames += 1
43
  print(f"Processing: {processed_frames}")
 
46
 
47
  cap.release()
48
  writer.release()
49
+ return tmpname + '.mp4'
50
 
51
  title = "🎞️Video Background Removal tool🎥"
52