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

想找手工活做 哪个网站可靠百度经验首页登录官网

想找手工活做 哪个网站可靠,百度经验首页登录官网,wordpress id连续,做企业云网站的企业大多数模型都是黑盒,其内部逻辑对最终用户是隐藏的。为了鼓励透明度,我们通过简单地将Interface类中的interpretation关键字设置为default,使得向模型添加解释变得非常容易。这允许您的用户了解输入的哪些部分负责输出。 1、Interpret解释 …

大多数模型都是黑盒,其内部逻辑对最终用户是隐藏的。为了鼓励透明度,我们通过简单地将Interface类中的interpretation关键字设置为default,使得向模型添加解释变得非常容易。这允许您的用户了解输入的哪些部分负责输出

1、Interpret解释 

我们来一个图片的分类器,带一个Interpret解释,这里将会下载人类可读的ImageNet标签,是在站点https://git.io/JJkYN上面返回的标签,所以需要用到科学上网。

import requests
import tensorflow as tfimport gradio as grinception_net = tf.keras.applications.MobileNetV2()  # 加载模型# 下载人类可读的ImageNet标签
response = requests.get("https://git.io/JJkYN")
labels = response.text.split("\n")def classify_image(inp):inp = inp.reshape((-1, 224, 224, 3))inp = tf.keras.applications.mobilenet_v2.preprocess_input(inp)prediction = inception_net.predict(inp).flatten()return {labels[i]: float(prediction[i]) for i in range(1000)}image = gr.Image(shape=(224, 224))
label = gr.Label(num_top_classes=3)#demo = gr.Interface(fn=classify_image, inputs=image, outputs=label, interpretation="default")
demo = gr.Interface(fn=classify_image, inputs=image, outputs=label, interpretation="shap", num_shap=5)demo.launch()

如下图,输入一张猫(猞猁)的图片,然后右边输出3个概率从大到小排序的分类标签:

然后点击Interpret,我们来看下效果,对重要部分进行了遮罩突出显示,也就是输出重要性判别的输入的地方做个解释。

2、高亮显示

适用于任何函数,即使在内部,模型是一个复杂的神经网络或其他黑盒子。如果使用Gradio的默认解释或形状解释,则输出组件必须是Label。支持所有常用输入组件。
下面是一个文本输入的示例:

import gradio as grmale_words, female_words = ["he", "his", "him"], ["she", "hers", "her"]def gender_of_sentence(sentence):male_count = len([word for word in sentence.split() if word.lower() in male_words])female_count = len([word for word in sentence.split() if word.lower() in female_words])total = max(male_count + female_count, 1)return {"male": male_count / total, "female": female_count / total}demo = gr.Interface(fn=gender_of_sentence,inputs=gr.Textbox(value="She went to his house to get her keys."),outputs="label",interpretation="default",
)demo.launch()

将显示男女比例,然后我们点击Interpret,将会看到界面会自动突出显示文本(或图像等)中重要部分。颜色的强度与输入部分的重要性相对应。降低类置信度的部分用蓝色突出显示。
 

3、常见错误处理 

3.1、安装tensorflow

我们安装任何包,个人依然推荐加豆瓣镜像

pip install -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com tensorflow

这里有个比较奇怪的问题,最开始我是这么安装,也是一直以来的常见安装方法:

pip install tensorflow -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com

看到区别了吗,就是将tensorflow放在了install后面,这样的情况会出现下面这样的错误:

WARNING: Ignoring invalid distribution -sonschema (d:\anaconda3\envs\pygpu\lib\site-packages)
WARNING: Ignoring invalid distribution -sonschema (d:\anaconda3\envs\pygpu\lib\site-packages)
Collecting http://pypi.douban.com/simple/
  Downloading http://pypi.douban.com/simple/ (24.7 MB)
     ---------------------------------------- 24.7/24.7 MB 11.9 MB/s eta 0:00:00
  ERROR: Cannot unpack file C:\Users\Tony\AppData\Local\Temp\pip-unpack-2d7n8372\simple.html (downloaded from C:\Users\Tony\AppData\Local\Temp\pip-req-build-5xqb8otu, content-type: text/html); cannot detect archive format
ERROR: Cannot determine archive format of C:\Users\Tony\AppData\Local\Temp\pip-req-build-5xqb8otu
WARNING: Ignoring invalid distribution -sonschema (d:\anaconda3\envs\pygpu\lib\site-packages)
WARNING: Ignoring invalid distribution -sonschema (d:\anaconda3\envs\pygpu\lib\site-packages)
WARNING: Ignoring invalid distribution -sonschema (d:\anaconda3\envs\pygpu\lib\site-packages)

翻译过来的意思就是:无法解包文件,无法检测存档格式,无法确定归档格式。

在以前安装tensorflow是在一个新的虚拟环境,没有问题,这个是在有MXNet的里面安装的,出现上述错误,然后试着将tensorflow放到最后面,没有想到竟然成功安装。

3.2、安装scikit-image

其中点击Interpret,需要安装skimage

ModuleNotFoundError: No module named 'skimage'

同样的方法安装即可,只不过这里需要注意名称 

pip install -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com scikit-image 

3.3、安装shap

指定一些参数,interpretation设置为shap,可以修改num_shap参数,该参数控制精度和运行时之间的权衡(增加该值通常会提高精度)。

demo = gr.Interface(fn=classify_image, inputs=image, outputs=label, interpretation="shap", num_shap=5)

在指定interpretation="shap"参数的时候,我们如果没有安装shape,也将报shap不存在的错误。

ModuleNotFoundError: No module named 'shap' 

pip install -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com shap

4、并行与串行

4.1、并行Parallel

Gradio可以让你很容易地使用Gradio来混合界面。
Parallel允许你将两个相似的模型(如果它们具有相同的输入类型)并行放置以比较模型预测 

generator1 = gr.load("huggingface/gpt2")
generator2 = gr.load("huggingface/EleutherAI/gpt-neo-2.7B")
generator3 = gr.load("huggingface/EleutherAI/gpt-j-6B")gr.Parallel(generator1, generator2, generator3).launch()

这样就可以比较几个模型的输出效果。

4.2、串行Series

我们也可以使用Series将两个模型串联起来,比如将第一个模型的输出作为第二个模型的输入,下面就是通过gpt2得到输出的信息,然后这些输出信息作为输入,进入t5-small模型,处理成德语进行最终的输出。 

generator = gr.load("huggingface/gpt2")
translator = gr.load("huggingface/t5-small")gr.Series(generator, translator).launch()

 如图,输出的英文再翻译成德语:

有兴趣的可以查阅其余章节:

Gradio的web界面演示与交互机器学习模型,安装和使用《1》
Gradio的web界面演示与交互机器学习模型,主要特征《2》
Gradio的web界面演示与交互机器学习模型,分享应用《3》
Gradio的web界面演示与交互机器学习模型,全局状态与会话状态《4》
Gradio的web界面演示与交互机器学习模型,接口自动刷新或连续刷新数据流《5》

http://www.hkea.cn/news/323046/

相关文章:

  • 怎么用网站做文案百度推广可以自己开户吗
  • 做的好的新闻网站排名优化
  • 购物网站开发功能百度联盟个人怎么接广告
  • 网站如何盈利流量费网站seo搜索引擎的原理是什么
  • 泰安房产价格最新域名年龄对seo的影响
  • 网站打不开怎么回事引流推广平台有哪些
  • 课程网站建设特色成都seo外包
  • 建设厅安全员证书查询网站外链seo推广
  • 邢台手机网站建设服务百度查重软件
  • 网站开发开题报告ppt竞价运营是做什么的
  • 网站代理怎么做的网站推广策划思路
  • 长沙网站seo公司百度权重5的网站能卖多少钱
  • 常德网站开发百度推广登录首页网址
  • 网站建设软件设计推广官网
  • 网站运营阶段站长之家app
  • discuz网站标题百度广告推广价格
  • 广州学校论坛网站建设疫情排行榜最新消息
  • 古董手表网站网络营销的主要方式和技巧
  • 做公司网站要那些资料百度电脑版下载官方
  • 定州网站建设公司企业网站源码
  • 0基础1小时网站建设教程如何给自己的公司建网站
  • 成都网站建设s1emens电商平台怎么加入
  • 六合哪家做网站建设域名注册查询软件
  • 网站建设的方案费用2023年新冠疫情最新消息
  • 九星市场做网站快速将网站seo
  • 长春做网站推广的公司提升神马关键词排名报价
  • 金融网站cms百度网盘客服电话人工服务
  • 美观网站建设物美价廉seo网站优化专员
  • 网站设计应该怎么做推广软文代写
  • 网站建设工作室发展百度收录教程