import paddlehub as hub import gradio as gr module = hub.Module(name="lseg") def segment(image, labels): results = module.segment( image=image[..., ::-1], labels=labels.split('\n') ) return [results['color'][..., ::-1], results['mix'][..., ::-1], *[v[..., ::-1] for v in results['classes'].values()]] gr.Interface(fn=segment, inputs=['image', gr.Textbox(placeholder='other\ncat', lines=5, max_lines=50)], outputs=['gallery']).launch()