Spaces:
Runtime error
Runtime error
| import os | |
| import numpy as np | |
| import gradio as gr | |
| from commons.selfie_seg import ( | |
| load_from_webcam, | |
| load_from_static_image, | |
| load_from_video | |
| ) | |
| # Optional[str | PIL.Image | np.narray] | |
| title = "Image and Video background changer" | |
| desc = "This simple app leverages google selfie segmentation via mediapipe to change background from bot images and videos. The \ | |
| backgroud type can be solid pictures, random images, or blur" | |
| imgs = os.listdir("bg_imgs/") | |
| rnd_img = "bg_imgs/" + np.random.choice(imgs) | |
| img_app = gr.Interface( | |
| load_from_static_image, | |
| [gr.Image(), gr.Dropdown(["random_image", "solid_colors", "blur"], label="Background Type", placeholder="Background type")], #,gr.Textbox(label="Background can be blur, a set of random_image, or a solid_colors")], # | |
| gr.Image() | |
| ) | |
| vid_app = gr.Interface( | |
| load_from_video, | |
| [gr.Video(source="upload"), gr.Dropdown(["ragindom_image", "solid_colors", "blur"], placeholder="Background type", show_label="Video")], | |
| [gr.Video(interactive=False, label="Video")] | |
| ) | |
| gr.TabbedInterface([img_app, vid_app], ["Image", "Video"]).launch( | |
| max_threads = 4) | |