gradio 机器学习应用共享框架

发布时间 2023-10-02 21:02:43作者: 荣锋亮

gradio 是一个机器学习应用共享框架,不少开源机器学习模型都基于gradio 提供了可以快速体验模型的ui

参考使用

  • 安装
pip install gradio
  • 简单代码
    app.py
 
import gradio as gr
 
def greet(name):
    return "Hello " + name + "!"
 
demo = gr.Interface(fn=greet, inputs="text", outputs="text")
 
demo.launch()
  • 启动&效果
gradio app.py 

效果
http://localhost:7860/

 

说明

对于需要将自己的模型快速共享别人使用的,gradio 是一个很不错的选择,huggingface 就基于gradio 提供了可视化测试的服务,同时gradio
提供了不少UI组件,可以让我们快速开发demo 服务

参考资料

https://www.gradio.app/guides/quickstart
https://github.com/gradio-app/gradio
https://huggingface.co/spaces/gradio/timeseries-forecasting-with-prophet/blob/main/app.py