import gradio as gr #导入gradio库,gradio用于快速创建机器学习模型的web界面
def reverse_text(text):
return text[::-1]
# 使用gr.Interface创建一个UI界面,fn指定了接口的函数,inputs定义了输入类型,outputs定义了输出类型
demo = gr.Interface(fn=reverse_text, inputs=["text"], outputs="text")
# 启动界面,这将会在本地服务器上运行web应用程序
demo.launch()
如图
