import gradio as gr import cv2 import numpy as np from transparent_background import Remover remover = Remover(mode='fast') # Custom setting def doo(video): cap = cv2.VideoCapture(video) # Video reader for input fps = cap.get(cv2.CAP_PROP_FPS) processed_frames = [] # List to store processed frames while cap.isOpened(): ret, frame = cap.read() # Read video if ret is False: break # Assuming frame is a NumPy array (e.g., shape: (height, width, 3)) # Perform background removal using the model # Replace this placeholder code with actual model inference # Example: Apply a simple threshold to create a binary mask gray_frame = cv2.cvtColor(frame, cv2.COLOR_RGB2GRAY) _, mask = cv2.threshold(gray_frame, 200, 255, cv2.THRESH_BINARY) # Create a masked frame masked_frame = cv2.bitwise_and(frame, frame, mask=mask) # Append the processed frame to the output processed_frames.append(masked_frame) cap.release() # Return the list of processed frames return processed_frames iface = gr.Interface(fn=doo, inputs="video", outputs="video") iface.launch()