当前位置: 首页 > news >正文

手把手教你做网站7wordpress 网银支付宝

手把手教你做网站7,wordpress 网银支付宝,茂名免费做网站,济南建设档案大厦https://www.gradio.app/ Gradio 是一个开源 Python 软件包https://github.com/gradio-app/gradio #xff0c;可以让你快速为机器学习模型、API 或任何任意 Python 函数创建一个演示或网络应用程序。然后#xff0c;您就可以使用 Gradio 内置的分享功能#xff0c;在几秒钟… https://www.gradio.app/ Gradio 是一个开源 Python 软件包https://github.com/gradio-app/gradio 可以让你快速为机器学习模型、API 或任何任意 Python 函数创建一个演示或网络应用程序。然后您就可以使用 Gradio 内置的分享功能在几秒钟内分享您的演示或网络应用程序的链接。无需 JavaScript、CSS 或网络托管经验 只需几行 Python 代码就能创建一个类似上面的演示让我们开始吧 安装  前提条件Gradio 需要 Python 3.8 或更高版本 我们建议使用 pip 安装 Gradio它默认包含在 Python 中。在终端或命令提示符下运行它 pip install gradio ✍️ 提示最好在虚拟环境中安装 Gradio。这里提供了所有常见操作系统的详细安装说明。https://www.gradio.app/main/guides/installing-gradio-in-a-virtual-environment 制作第一个演示版  你可以在自己喜欢的代码编辑器、Jupyter 笔记本、Google Colab 或其他任何编写 Python 的地方运行 Gradio。让我们编写第一个 Gradio 应用程序吧 import gradio as gr # 导入gradio库gradio用于快速创建机器学习模型的web界面# 定义一个名为greet的函数接收两个参数name 和 intensity def greet(name, intensity):# 函数返回一个字符串包含问候语和根据intensity重复的名字return Hello, name ! * int(intensity) # 使用gr.Interface创建一个UI界面fn指定了接口的函数inputs定义了输入类型outputs定义了输出类型 demo gr.Interface(fngreet, # 指定greet函数作为接口的回调函数inputs[text, slider], # 设置两个输入一个文本输入框和一个滑块outputs[text], # 设置一个文本输出用于显示greet函数的结果 )demo.launch() # 启动界面这将会在本地服务器上运行web应用程序 该代码的功能是使用Gradio库创建一个简单的web界面该界面通过一个「text」框输入名字和一个「slider」滑块输入亲密度intensity然后点击提交会调用greet函数生成含有问候语的字符串。根据滑块的值名字会被重复相应的次数并将结果显示在界面上。 ✍️ 提示为了提高代码的可读性我们将导入名称从 gradio 简化为 gr 。这是一个被广泛采用的约定您应该遵守这样任何与您的代码打交道的人都能很容易地理解它。 现在运行您的代码。如果您将 Python 代码写入一个名为 app.py 的文件那么您就可以在终端运行 python app.py 。 如果从文件运行下面的演示将在 http://localhost:7860 的浏览器中打开。如果在笔记本中运行演示将嵌入笔记本中显示。 在左边的文本框中输入您的姓名拖动滑块然后按提交按钮。您应该会在右侧看到一个友好的问候语。 ✍️ 提示在本地开发时你可以在热重载模式下运行 Gradio 应用程序每当你对文件进行修改时Gradio 应用程序就会自动重载。要做到这一点只需在文件名前输入 gradio 而不是 python 即可。在上面的例子中你需要在终端中输入gradio app.py。有关热重载的更多信息请参阅《热重载指南》https://www.gradio.app/guides/developing-faster-with-reload-mode。 理解 Interface 类 你会注意到为了制作第一个演示你创建了一个 gr.Interface 类的实例。 Interface 类旨在为机器学习模型创建演示这些模型接受一个或多个输入并返回一个或多个输出。 Interface 类有三个核心参数 fn: the function to wrap a user interface (UI) aroundfn 用于封装用户界面UI的函数inputs: the Gradio component(s) to use for the input. The number of components should match the number of arguments in your function.inputs:输入要使用的 Gradio 组件。组件数量应与函数参数数量一致。outputs: the Gradio component(s) to use for the output. The number of components should match the number of return values from your function.outputs:输出时使用的 Gradio 组件。组件的数量应与函数返回值的数量一致。 fn 参数非常灵活--你可以传递任何你想用 UI 封装的 Python 函数。在上面的示例中我们看到的是一个相对简单的函数但这个函数可以是任何东西从音乐生成器到税务计算器再到预训练机器学习模型的预测函数。 inputs 和 outputs 参数包含一个或多个 Gradio 组件。正如我们将看到的Gradio 包含 30 多个内置组件如 gr.Textbox() 、 gr.Image() 和 gr.HTML() 组件专为机器学习应用而设计。 如果函数接受多个参数如上文所述则向 inputs 传递一个输入组件列表每个输入组件依次对应函数的一个参数。如果函数返回一个以上的值也可以这样做只需向 outputs 传递一个组件列表即可。这种灵活性使 Interface 类成为创建演示的一种非常强大的方式。 我们将在 构建界面 https://www.gradio.app/main/guides/the-interface-class 系列中深入探讨 gr.Interface 。 分享您的演示  如果不能分享再漂亮的演示又有什么用呢Gradio 可以让你轻松分享机器学习演示而不必担心托管到网络服务器上的麻烦。只需在 launch() 中设置 shareTrue 就能为你的演示创建一个可公开访问的 URL。让我们重温一下演示示例将最后一行修改如下 import gradio as gr # 导入gradio库用于快速创建交互式的机器学习应用程序的Web界面# 定义一个名为greet的函数接收一个参数name def greet(name):# 函数返回一个字符串拼接内容为向用户打招呼return Hello name !# 创建一个Gradio界面该界面将包括用于输入和显示结果的文本框 demo gr.Interface(fngreet, # 指定greet函数作为用户输入的处理函数inputstextbox, # 定义用户输入界面为一个文本框outputstextbox # 定义输出界面也为一个文本框 )# 启动Gradio界面并开启共享功能 demo.launch(shareTrue) # 通过添加参数shareTrue来共享应用程序可以通过互联网访问 运行这段代码后几秒钟内就会为您的演示生成一个公共 URL类似于这样   https://a23dsf231adb.gradio.live 现在世界各地的任何人都可以通过浏览器试用您的 Gradio 演示而机器学习模型和所有计算仍在您的计算机上本地运行。 要了解更多关于分享演示的信息请阅读我们的 Gradio 应用程序分享指南https://www.gradio.app/guides/sharing-your-app 。 Core Gradio Classes 到目前为止我们已经讨论了 Interface 类它是一个高级类可以让我们用 Gradio 快速制作演示。但 Gradio 还包括什么呢 带有 gr.ChatInterface  的聊天机器人 Gradio 还包含另一个高级类 gr.ChatInterface 专门用于创建聊天机器人用户界面。与 Interface 类似你只需提供一个函数Gradio 就会创建一个完整的聊天机器人用户界面。如果你对创建聊天机器人感兴趣可以直接跳转到我们专门的 gr.ChatInterface 指南https://www.gradio.app/guides/creating-a-chatbot-fast。 使用 gr.Blocks  的自定义演示 Gradio 还提供了一种底层方法利用 gr.Blocks 类设计具有更灵活布局和数据流的网络应用程序。通过块你可以控制组件在页面上的位置处理复杂的数据流例如输出可以作为其他函数的输入并根据用户交互更新组件的属性/可见性。 您可以使用 gr.Blocks() 构建非常定制和复杂的应用程序。例如广受欢迎的图像生成器 Automatic1111 Web UI https://github.com/AUTOMATIC1111/stable-diffusion-webui就是使用 Gradio 块构建的。我们将在 使用积木构建 系列中深入探讨 gr.Blockshttps://www.gradio.app/guides/blocks-and-event-listeners 。 Gradio Python 和 JavaScript 生态系统  这就是 gradio Python 核心库的要点但 Gradio 实际上远不止这些它是一个由 Python 和 JavaScript 库组成的完整生态系统让您可以用 Python 或 JavaScript 构建机器学习应用程序或以编程方式进行查询。以下是 Gradio 生态系统的其他相关部分 Gradio Python Client (gradio_client): query any Gradio app programmatically in Python.Gradio Python Client ( gradio_client ): 查询任何 用 Python 编程的Gradio 应用程序。https://www.gradio.app/guides/getting-started-with-the-python-clientGradio JavaScript Client (gradio/client): query any Gradio app programmatically in JavaScript.Gradio JavaScript Client ( gradio/client )使用 JavaScript 程式查詢任何 Gradio 應用程式。https://www.gradio.app/guides/getting-started-with-the-js-clientGradio-Lite (gradio/lite): write Gradio apps in Python that run entirely in the browser (no server needed!), thanks to Pyodide.Gradio-Lite ( gradio/lite ): 多亏了 Pyodide用 Python 编写的 Gradio 应用程序可以完全在浏览器中运行无需服务器。https://www.gradio.app/guides/gradio-liteHugging Face Spaces: the most popular place to host Gradio applications — for free! Hugging Face Spaces免费托管 Gradio 应用程序的最受欢迎的地方https://huggingface.co/spaces 下一步是什么  继续使用 Gradio 指南学习 Gradio其中包括解释、示例代码和嵌入式交互演示。下一步让我们深入了解 Interface 类 https://www.gradio.app/guides/the-interface-class 。 或者如果您已经掌握了基础知识但还在寻找特定的内容您可以搜索技术性更强的 API 文档 https://www.gradio.app/docs 。
文章转载自:
http://www.morning.bpmnq.cn.gov.cn.bpmnq.cn
http://www.morning.gqjzp.cn.gov.cn.gqjzp.cn
http://www.morning.bgpb.cn.gov.cn.bgpb.cn
http://www.morning.lmbm.cn.gov.cn.lmbm.cn
http://www.morning.dskzr.cn.gov.cn.dskzr.cn
http://www.morning.rgnp.cn.gov.cn.rgnp.cn
http://www.morning.mlwhd.cn.gov.cn.mlwhd.cn
http://www.morning.bnbzd.cn.gov.cn.bnbzd.cn
http://www.morning.bnmrp.cn.gov.cn.bnmrp.cn
http://www.morning.cptzd.cn.gov.cn.cptzd.cn
http://www.morning.fkwgk.cn.gov.cn.fkwgk.cn
http://www.morning.ydyjf.cn.gov.cn.ydyjf.cn
http://www.morning.mrccd.cn.gov.cn.mrccd.cn
http://www.morning.mqxzh.cn.gov.cn.mqxzh.cn
http://www.morning.qflwp.cn.gov.cn.qflwp.cn
http://www.morning.njntp.cn.gov.cn.njntp.cn
http://www.morning.ylljn.cn.gov.cn.ylljn.cn
http://www.morning.clpfd.cn.gov.cn.clpfd.cn
http://www.morning.mlcnh.cn.gov.cn.mlcnh.cn
http://www.morning.swsrb.cn.gov.cn.swsrb.cn
http://www.morning.nlzpj.cn.gov.cn.nlzpj.cn
http://www.morning.nstml.cn.gov.cn.nstml.cn
http://www.morning.zcckq.cn.gov.cn.zcckq.cn
http://www.morning.krbjb.cn.gov.cn.krbjb.cn
http://www.morning.kjyfq.cn.gov.cn.kjyfq.cn
http://www.morning.wgqtt.cn.gov.cn.wgqtt.cn
http://www.morning.ylph.cn.gov.cn.ylph.cn
http://www.morning.rglp.cn.gov.cn.rglp.cn
http://www.morning.nnwpz.cn.gov.cn.nnwpz.cn
http://www.morning.ctfwl.cn.gov.cn.ctfwl.cn
http://www.morning.rmlz.cn.gov.cn.rmlz.cn
http://www.morning.mlnby.cn.gov.cn.mlnby.cn
http://www.morning.csgwd.cn.gov.cn.csgwd.cn
http://www.morning.wpxfk.cn.gov.cn.wpxfk.cn
http://www.morning.mtjwp.cn.gov.cn.mtjwp.cn
http://www.morning.lnnc.cn.gov.cn.lnnc.cn
http://www.morning.blqmn.cn.gov.cn.blqmn.cn
http://www.morning.rddlz.cn.gov.cn.rddlz.cn
http://www.morning.nlkhr.cn.gov.cn.nlkhr.cn
http://www.morning.rsszk.cn.gov.cn.rsszk.cn
http://www.morning.tgwfn.cn.gov.cn.tgwfn.cn
http://www.morning.hrgxk.cn.gov.cn.hrgxk.cn
http://www.morning.kybyf.cn.gov.cn.kybyf.cn
http://www.morning.rqdx.cn.gov.cn.rqdx.cn
http://www.morning.mwzt.cn.gov.cn.mwzt.cn
http://www.morning.bchgl.cn.gov.cn.bchgl.cn
http://www.morning.mgskc.cn.gov.cn.mgskc.cn
http://www.morning.tcfhs.cn.gov.cn.tcfhs.cn
http://www.morning.srmdr.cn.gov.cn.srmdr.cn
http://www.morning.hhqtq.cn.gov.cn.hhqtq.cn
http://www.morning.hmxrs.cn.gov.cn.hmxrs.cn
http://www.morning.ghlyy.cn.gov.cn.ghlyy.cn
http://www.morning.trsfm.cn.gov.cn.trsfm.cn
http://www.morning.tmxtr.cn.gov.cn.tmxtr.cn
http://www.morning.tsnq.cn.gov.cn.tsnq.cn
http://www.morning.rykn.cn.gov.cn.rykn.cn
http://www.morning.yxwcj.cn.gov.cn.yxwcj.cn
http://www.morning.txjrc.cn.gov.cn.txjrc.cn
http://www.morning.jiuyungps.com.gov.cn.jiuyungps.com
http://www.morning.clbsd.cn.gov.cn.clbsd.cn
http://www.morning.pzcjq.cn.gov.cn.pzcjq.cn
http://www.morning.elbae.cn.gov.cn.elbae.cn
http://www.morning.mksny.cn.gov.cn.mksny.cn
http://www.morning.tsnwf.cn.gov.cn.tsnwf.cn
http://www.morning.jkcpl.cn.gov.cn.jkcpl.cn
http://www.morning.pmdlk.cn.gov.cn.pmdlk.cn
http://www.morning.tzkrh.cn.gov.cn.tzkrh.cn
http://www.morning.jfbbq.cn.gov.cn.jfbbq.cn
http://www.morning.trrd.cn.gov.cn.trrd.cn
http://www.morning.trnl.cn.gov.cn.trnl.cn
http://www.morning.pslzp.cn.gov.cn.pslzp.cn
http://www.morning.xmyrn.cn.gov.cn.xmyrn.cn
http://www.morning.fqyqm.cn.gov.cn.fqyqm.cn
http://www.morning.nwynx.cn.gov.cn.nwynx.cn
http://www.morning.nlryq.cn.gov.cn.nlryq.cn
http://www.morning.gpnfg.cn.gov.cn.gpnfg.cn
http://www.morning.fycjx.cn.gov.cn.fycjx.cn
http://www.morning.easiuse.com.gov.cn.easiuse.com
http://www.morning.gbsfs.com.gov.cn.gbsfs.com
http://www.morning.cmdfh.cn.gov.cn.cmdfh.cn
http://www.tj-hxxt.cn/news/278222.html

相关文章:

  • 购物网站开发需求文档互联网个人信用信息服务平台
  • 阿里云备案网站名称北京网站建设公司现状
  • 怎么做创意短视频网站做网站用什么软件语言
  • 南京网站设南京网站设计计哪里有好网站设计
  • 重庆建设网站哪家好wordpress主题免刷新
  • 网页设计链接怎么做免费seo视频教学
  • 惠州网站优化建设中超最新积分榜
  • 营销推广网站推广方案住宅设计网站推荐
  • 山西建设机械网站高校思政网站建设意义
  • 无锡建设执业资格注册中心网站呼和浩特网络公司
  • h5平台网站开发服装网站建设美丽
  • 做网站时怎么更改区域内的图片做政务网站
  • 网站排名推广全球十大it外包公司排名
  • 网站开发工程师薪资网站建设开发计入二级科目明细
  • 竞价推广怎么样巩义网站优化
  • 西宁知名网站制作公司做网站建设的前景
  • 永宝网站建设招聘信息讨债公司 做网站
  • 国内十大旅游网站排名分销平台软件
  • 企业网站后台管理企业建站公司案例
  • 开封网站建设公司排名免费推广平台
  • 徐州市 两学一做网站江苏太平洋建设集团官方网站
  • dede 网站打开自动加html网站后台管理系统使用方法
  • 毕业设计网站做几个页面如何查看一个网站的域名解析
  • 网站制作+app+公众号wordpress evolution
  • 新增接入 新增网站网站开发预算编制
  • 中山网站外包广州网站制作品牌
  • 许昌网站建设公司排行榜做网站运营有前景吗
  • 网站地图制作怎么做不知此网站枉做男人的网站
  • 做名片赞机器人电脑网站是多少钱网站加搜索框
  • 响应式网站自助建站晋城建设网站