File size: 841 Bytes
1f25689
 
2064e3d
1f25689
2064e3d
 
 
1f25689
 
 
 
 
 
 
 
 
 
 
 
 
2064e3d
 
1f25689
 
 
 
 
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
import numpy as np
import gradio as gr
import cv2

def to_black(image):
    output = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
    return output

with gr.Blocks() as demo:
    gr.Markdown("Flip image or video files using this demo.")
    with gr.Tabs():
        with gr.TabItem("Flip Image"):
            with gr.Row():
                image_input = gr.Image()
                image_output = gr.Image()
            image_button = gr.Button("Flip")
        with gr.TabItem("Flip Video"):
            video_input = gr.Video()
            video_output = gr.Video()
            video_button = gr.Button("Flip")
    image_button.click(to_black, inputs=image_input, outputs=image_output)
    video_button.click(to_black, inputs=video_input, outputs=video_output)

demo.launch()

# 启动接口
#demo.launch(server_name='127.0.0.1',server_port=7788)