amirgame197 commited on
Commit
d4ae210
1 Parent(s): 1a37b1b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -23
app.py CHANGED
@@ -10,31 +10,28 @@ remover = Remover()
10
 
11
  @spaces.GPU
12
  def doo(video):
13
- try:
14
- cap = cv2.VideoCapture(video)
15
- fps = cap.get(cv2.CAP_PROP_FPS)
16
-
17
- processed_frames = 0
18
- writer = None
19
-
20
- while cap.isOpened():
21
- ret, frame = cap.read()
22
-
23
- if ret is False:
24
- break
25
-
26
- frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
27
- img = Image.fromarray(frame).convert('RGB')
28
 
29
- if writer is None:
30
- writer = cv2.VideoWriter('output.mp4', cv2.VideoWriter_fourcc(*'mp4v'), fps, img.size)
31
 
32
- processed_frames += 1
33
- print(f"Processing: {processed_frames}")
34
- out = remover.process(img, type='green')
35
- writer.write(cv2.cvtColor(np.array(out), cv2.COLOR_BGR2RGB))
36
- except:
37
- pass
 
 
 
 
 
 
 
38
  cap.release()
39
  writer.release()
40
  return 'output.mp4'
 
10
 
11
  @spaces.GPU
12
  def doo(video):
13
+ cap = cv2.VideoCapture(video)
14
+ fps = cap.get(cv2.CAP_PROP_FPS)
15
+
16
+ processed_frames = 0
17
+ writer = None
 
 
 
 
 
 
 
 
 
 
18
 
19
+ while cap.isOpened():
20
+ ret, frame = cap.read()
21
 
22
+ if ret is False:
23
+ break
24
+
25
+ frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
26
+ img = Image.fromarray(frame).convert('RGB')
27
+
28
+ if writer is None:
29
+ writer = cv2.VideoWriter('output.mp4', cv2.VideoWriter_fourcc(*'mp4v'), fps, img.size)
30
+
31
+ processed_frames += 1
32
+ print(f"Processing: {processed_frames}")
33
+ out = remover.process(img, type='green')
34
+ writer.write(cv2.cvtColor(np.array(out), cv2.COLOR_BGR2RGB))
35
  cap.release()
36
  writer.release()
37
  return 'output.mp4'