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

html做游戏网站网站建设公司营销话术

html做游戏网站,网站建设公司营销话术,找百度,公司必备的几个部门gradio是一款基于python的算法快速部署工具#xff0c;本博文主要介绍使用gradio部署目标检测、图像分类、语义分割模型的部署。相比于flask#xff0c;使用gradio不需要自己构造前端代码#xff0c;只需要将后端接口写好即可。此外#xff0c;基于gradio实现的项目#x…gradio是一款基于python的算法快速部署工具本博文主要介绍使用gradio部署目标检测、图像分类、语义分割模型的部署。相比于flask使用gradio不需要自己构造前端代码只需要将后端接口写好即可。此外基于gradio实现的项目可以托管到huggingface。 官网地址https://www.gradio.app/guides/quickstart 文档地址https://www.gradio.app/docs/interface 优质教程https://zhuanlan.zhihu.com/p/624712372 安装命令pip install gradio 托管到huggingface具体步骤如下 1、基本用法 1.1 输入图像返回文本 基本使用方法如下所示 import gradio as grdef image_classifier(inp):return {cat: 0.3, dog: 0.7}demo gr.Interface(fnimage_classifier, inputsimage, outputslabel) demo.launch()每一个参数的描述如下所示 页面部署效果如下所示 1.2 输入文本返回文本 import random import gradio as grdef random_response(message, history):return random.choice([Yes message, Nomessage])demo gr.ChatInterface(random_response, examples[hello, hola, merhaba], titleEcho Bot)if __name__ __main__:demo.launch()1.3 输入图像返回图像 import numpy as np import gradio as gr def sepia(input_img):#处理图像sepia_filter np.array([[0.393, 0.769, 0.189],[0.349, 0.686, 0.168],[0.272, 0.534, 0.131]])sepia_img input_img.dot(sepia_filter.T)sepia_img / sepia_img.max()return sepia_img #shape设置输入图像大小 #demo gr.Interface(sepia, gr.Image(height200, width200), image) demo gr.Interface(sepia, inputsgr.Image(), outputsimage) demo.launch()2、部署模型 以下部署代码中的ppDeploy 源自博客paddle 57 基于paddle_infer以面向对象方式2行代码部署目标检测模型、图像分类模型、语义分割模型 2.1 图像分类 部署代码如下所示 from ppDeploy import * import gradio as gr from PIL import ImageclsclsModel(model/resnet50/,imagenet1000.txt,imgsz256) def cls_predict(input_img):rescls.forword(input_img,topk5)print(res)return resif __name____main__:gr.close_all() demo gr.Interface(fn cls_predict,inputs gr.Image(typepil), outputs gr.Label(num_top_classes5), examples [examples/1.jpg,examples/2.jpg,examples/3.jpg,examples/4.jpg,examples/5.jpg,])demo.launch()部署效果如下所示 2.2 目标检测 部署代码如下所示其特点是输入为imagefloat输出为flaot然后examples 需要给出多个在显示时变成了表格 from ppDeploy import * import gradio as gr from PIL import Image#clsclsModel(model/resnet50/,imagenet1000.txt,imgsz256) detdetModel(model/ppyoloe_m/,object365.txt,imgsz640) def det_predict(input_img,conf):resdet.forword(input_img,conf)return res if __name____main__:gr.close_all() #demo gr.Interface(fn cls_predict,inputs gr.Image(typepil), outputs gr.Label(num_top_classes5), examples [examples/1.jpg,examples/2.jpg,examples/3.jpg,examples/4.jpg,examples/5.jpg,])demo gr.Interface(fn det_predict,inputs [gr.Image(typepil),gr.Number(precision2,minimum0.01,maximum1,value0.3)], outputs image,examples [[examples/1.jpg,0.3],[examples/2.jpg,0.3],[examples/3.jpg,0.3],[examples/4.jpg,0.3],[examples/5.jpg,0.3],])demo.launch()运行效果如下所示 通过对部署代码进行修改examples仅给出一个nx1的二维数组其又变成了图片列表 from ppDeploy import * import gradio as gr from PIL import Image#clsclsModel(model/resnet50/,imagenet1000.txt,imgsz256) detdetModel(model/ppyoloe_m/,object365.txt,imgsz640) def det_predict(input_img,conf):resdet.forword(input_img,conf)return res if __name____main__:gr.close_all() #demo gr.Interface(fn cls_predict,inputs gr.Image(typepil), outputs gr.Label(num_top_classes5), examples [examples/1.jpg,examples/2.jpg,examples/3.jpg,examples/4.jpg,examples/5.jpg,])demo gr.Interface(fn det_predict,inputs [gr.Image(typepil),gr.Number(precision2,minimum0.01,maximum1,value0.3)], outputs image,examples [[examples/1.jpg],[examples/2.jpg],[examples/3.jpg],[examples/4.jpg],[examples/5.jpg],])demo.launch()此时执行效果如下所示 2.3 语义分割 部署代码如下 from ppDeploy import * import gradio as gr from PIL import Image#clsclsModel(model/resnet50/,imagenet1000.txt,imgsz256) #detdetModel(model/ppyoloe_m/,object365.txt,imgsz640) segsegModel(model/segformerb1/,imgsz1024) def seg_predict(input_img,conf):resseg.forword(input_img,conf)return res if __name____main__:gr.close_all() #demo gr.Interface(fn cls_predict,inputs gr.Image(typepil), outputs gr.Label(num_top_classes5), examples [examples/1.jpg,examples/2.jpg,examples/3.jpg,examples/4.jpg,examples/5.jpg,])demo gr.Interface(fn seg_predict,inputs [gr.Image(typepil)], outputs image,examples [examples/1.jpg,examples/2.jpg,examples/3.jpg,examples/4.jpg,examples/5.jpg,])demo.launch()部署效果如下 3、同时部署多个模型 3.1 部署代码 通过以下代码可以用选项卡的形式同时部署3个模型。 以下代码中通过with gr.Tab(图像分类):可以开启一个新的选项卡通过with gr.Row():可以强制是控件在同一行通过with gr.Column():可以强制使控件在同一列。具体效果图见章节3.2 from ppDeploy import * import gradio as gr from PIL import Imagewith gr.Blocks() as demo:gr.Markdown(功能选项卡)with gr.Tab(图像分类):cls_input gr.Image(typepil)cls_button gr.Button(submit,)cls_output gr.Label(num_top_classes5)gr.Examples(examples[examples/1.jpg,examples/2.jpg,examples/3.jpg,examples/4.jpg,examples/5.jpg,],inputs[cls_input])with gr.Tab(语义分割):with gr.Row():with gr.Column():seg_input gr.Image(typepil)seg_button gr.Button(submit)with gr.Column():seg_output gr.Image(typepil)gr.Examples(examples[examples/1.jpg,examples/2.jpg,examples/3.jpg,examples/4.jpg,examples/5.jpg,],inputs[seg_input])with gr.Tab(目标检测):with gr.Row():with gr.Column():det_input_image gr.Image(typepil)det_input_number gr.Number(precision2,minimum0.01,maximum1,value0.3,label置信度)det_button gr.Button(submit)with gr.Column():det_output gr.Image(typepil)gr.Examples(examples[examples/1.jpg,examples/2.jpg,examples/3.jpg,examples/4.jpg,examples/5.jpg,],inputs[det_input_image])#[[examples/1.jpg],[examples/2.jpg],[examples/3.jpg],[examples/4.jpg],[examples/5.jpg],[examples/6.jpg],]with gr.Accordion(功能说明):gr.Markdown(点击选项卡可以切换功能选项点击Examples中的图片可以使用示例图片)clsclsModel(model/resnet50/,imagenet1000.txt,imgsz256)detdetModel(model/ppyoloe_m/,object365.txt,imgsz640)segsegModel(model/segformerb1/,imgsz1024)cls_button.click(cls.forword, inputscls_input, outputscls_output)seg_button.click(seg.forword, inputsseg_input, outputsseg_output)det_button.click(det.forword, inputs[det_input_image,det_input_number], outputsdet_output)if __name__ __main__:demo.launch() 3.2 部署效果 图像分类效果 语义分割效果 目标检测效果
http://www.pierceye.com/news/22704/

相关文章:

  • 用asp做网站需要安装什么软件西安做小程序的公司
  • wordpress网站搬家图片路径石家庄网站建设联系电话
  • 怎么查网站备案域名备案信息zzcms网站开发
  • 国内最好软件网站建设微信网站是什么意思
  • 社区网站如何做网站浏览图片怎么做的
  • 商城网站前置审批唐山建设招聘信息网站
  • 陕西网站备案 多久太原建南站
  • 内江住房和城乡建设厅网站网站建设企业公司
  • 山东省建设执业官方网站怎么制作网站的二维码
  • 如何申请网站空间和域名活码二维码生成器
  • 快手流量推广网站微信小程序如何做
  • 湖北专业网站建设耗材百度指数官网查询
  • 百度网站加v旅游网站的设计的前提
  • 专业企业网站建设报价chrome浏览器
  • php 网站制作的意义做网站公司名字
  • 灰色 网站南昌seo推广方式
  • 南昌外贸网站设计来宾北京网站建设
  • 电子商务网站建设规划报告书东莞企业画册设计制作公司报价
  • 做竞争小的网站室内设计网站导航
  • 学做网站需要Wordpress 收费优化
  • 大连网站建设顾问asp网站安装教程
  • 做云盘网站哪个好专业做鞋子网站有哪些
  • 网站闭站保护数据库网站开发价格
  • 中国住房和建设部厅查询网站wordpress页面路径
  • 网站建设现在什么服务器比较好手机网站flash
  • 完成网站集约化建设网站的性质和主办者
  • 个人网站免费域名获取百度手机端排名
  • 免费模板的软件南阳网站优化哪家好
  • 专业的集团网站建设哪家网站建设合同概念
  • 做简单手机网站多少钱呀html菜鸟初学