Gradio学习(一)—————启动一个demo页面

安装(Python 3.7以上版本)

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple gradio

新建一个demo文件

import gradio as gr

def greet(name):

return "hello "+name+"!"

demo=gr.Interface(fn=greet,inputs="text",output="text")

因为在虚拟机中启动,而不是pycharm 所以指定主机ip (1.1.1.1)和端口号,如果是在pycharm 中,无需指定

demo.launch(server_name="1.1.1.1",server_port=7860,share=True,inbrowser=True)

相关推荐
电饭叔3 小时前
python转换字符串介绍
开发语言·windows·python
doris82043 小时前
Python 正则表达式 re.findall()
java·python·正则表达式
Mrliu__3 小时前
Python高级技巧(六):正则表达式
开发语言·python·正则表达式
码路飞4 小时前
Gemini 3.1 Pro 发布 3 天,我用同一个 API 跑了 3 家大模型横评,结果有点意外
python
癫狂的兔子5 小时前
【Python】【机器学习】贝叶斯算法
python·机器学习
代码小书生5 小时前
pillow,一个实用的 Python 库!
开发语言·python·pillow
A懿轩A5 小时前
【Java 基础编程】Java 异常处理保姆级教程:try-catch-finally、throw/throws、自定义异常
java·开发语言·python
追求源于热爱!5 小时前
记10,Gradio介绍
python
破晓之翼6 小时前
Skill原理及国内大模型实践
人工智能·python
IT管理圈6 小时前
Cursor Rules 实战指南—让AI按你的规矩写代码
python