File size: 1,215 Bytes
077d557
de2aa9b
d34396b
 
e50e349
d34396b
 
ba4d1a9
671a10f
 
172a03a
ba4d1a9
172a03a
 
 
 
63b8881
172a03a
63b8881
172a03a
e50e349
172a03a
 
 
 
 
d4ae210
172a03a
 
63b8881
172a03a
 
d4ae210
172a03a
 
63b8881
172a03a
 
b25a6ce
172a03a
 
 
 
 
 
 
5be44ed
ce6434e
9444948
63b8881
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import spaces
import gradio as gr
#import cv2
#import numpy as np

#from PIL import Image
#from transparent_background import Remover

import rembg

#remover = Remover()

#@spaces.GPU
#def doo(video):
    #cap = cv2.VideoCapture(video)
    #fps = cap.get(cv2.CAP_PROP_FPS)
    
    #writer = None
    
    #processed_frames = 0
    
    #while cap.isOpened():
    #    ret, frame = cap.read()
    #
    #    if ret is False:
    #        break
            
    #    frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB) 
    #    img = Image.fromarray(frame).convert('RGB')
    
    #    if writer is None:
    #        writer = cv2.VideoWriter('output.mp4', cv2.VideoWriter_fourcc(*'mp4v'), fps, img.size)

    #    processed_frames += 1
    #    print(f"Processing: {processed_frames}")
        
    #    out = remover.process(img, type='green')
    #    writer.write(cv2.cvtColor(np.array(out), cv2.COLOR_BGR2RGB))
    
    #cap.release()
    #writer.release()
    #return 'output.mp4'

@spaces.GPU
def doo(video):
    rembg.greenscreen(video, gpu=True, output="output.mp4", format="mp4", alpha=True, gpubatchsize=10)
    return 'output.mp4'

iface = gr.Interface(fn=doo, inputs="video", outputs="video")
iface.launch()