File size: 731 Bytes
84ea4a7
526afc6
 
 
 
84ea4a7
 
526afc6
 
 
 
 
 
 
 
 
 
 
dc3ca58
526afc6
 
 
 
 
 
 
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
import gradio as gr
import cv2
from PIL import Image
import numpy as np
from gradio import components


def segment_and_show(image):
    image = cv2.cvtColor(np.array(image), cv2.COLOR_RGB2BGR)

    # TODO: Implement segmentation logic here
    return Image.fromarray(cv2.cvtColor(image, cv2.COLOR_BGR2RGB))


default_image = Image.open("demo.jpeg")

iface = gr.Interface(
    fn=segment_and_show,
    inputs=components.Image(value=default_image, sources=["upload", "clipboard"]),
    outputs=components.Image(type="pil"),
    title="Urban Autonomy Instance Segmentation Demo",
    description="Upload an image or use the default to see the instance segmentation model in action.",
)

if __name__ == "__main__":
    iface.launch()