cent ultraiso_园丁cent vs千足的web ai应用

cent ultraiso

ML Model Deployment with fastai and Binder

使用fastai和Binder进行ML模型部署

Centipedes and millipedes are two creatures that one can encounter in the garden. Centipedes are beneficial to you because they feed on mites, insect larvae, insects, baby snails, and slugs. Millipedes, on the other hand, can be harmful and feed on plant roots, germinating seeds, and seedlings. Therefore it is beneficial to any gardener to be able to distinguish between the two.

mill和千足虫是一种可以在花园中遇到的两种生物。 they对您有好处,因为它们以螨,昆虫幼虫,昆虫,小蜗牛和为食。 另一方面,千足虫可能有害,并以植物根,发芽的种子和幼苗为食。 因此,能够区分两者对任何园丁都是有益的。

Being inspired by the beautiful book “Deep Learning for Coders with fastai and PyTorch: AI Applications Without a PhD” by Jeremy Howard and Sylvain Gugger, I decided to make a simple AI app for my wife, who is an avid gardener, that would help with the classification of centipedes and millipedes.

受到杰里米·霍华德(Jeremy Howard)和席尔文·古格(Sylvain Gugger)的一本精美的书《 使用Fastai和PyTorch进行代码深度学习:没有博士学位的AI应用程序 》的启发,我决定为我的妻子(一个狂热的园丁)制作一个简单的AI应用程序,这将对您有所帮助与ipe和千足虫的分类。

Dataset: I used Microsoft Bing Image Search API to collect images. After data cleanup, I ended up with 80 images of centipedes and 68 images of millipedes, split 80/20 for training and validation.

数据集:我使用Microsoft Bing图像搜索API来收集图像。 数据清理后,我得到80张images图像和68张千足图像,将80/20分割以进行训练和验证。

Machine learning model: I used the fastai vision library to build and train my model. Initially, I used ResNet34 as my pretrained model, but the resulting pickle file (file containing the trained model with weights) was too big for the app’s proper function. I downsized this file from 81 MB to 47 MB by going with ResNet18 instead.

机器学习模型:我使用fastai视觉库来构建和训练我的模型。 最初,我使用ResNet34作为预训练模型,但是生成的pickle文件(包含带有权重的训练模型的文件)对于应用程序的正常功能而言太大。 通过使用ResNet18,我将该文件的大小从81 MB减小到47 MB​​。

Image for post

After only ten epochs, the model achieved 93% accuracy.

仅十个星期之后,该模型就达到了93%的准确性。

Image for post

Only two images were misclassified in the validation set (see confusion matrix above.

验证集中只有两张图像被错误分类(请参阅上面的混淆矩阵。

Making a Jupyter notebook widget: Using widgets, I created a simple prediction app following Jeremy’s book’s instructions (please see my GitHub repository for the notebook file).

制作Jupyter笔记本小部件:使用小部件,我按照Jeremy的书的说明创建了一个简单的预测应用程序(请参阅我的GitHub存储库中的笔记本文件)。

The next step was to deploy a local app to the web. One of the easiest ways to do that is to use Binder. Binder allows running Jupyter notebooks in an executable environment on the web.

下一步是将本地应用程序部署到Web。 最简单的方法之一就是使用Binder 。 活页夹允许在网络上的可执行环境中运行Jupyter笔记本。

Image for post
Source: https://mybinder.org/
资料来源: https : //mybinder.org/

You can upload your GitHub repository straight to the Binder website.The GitHub repository must contain at least free files: Jupyter notebook with code, pickle file with your model and weights, and requirements.txt file to create your python environment. To bypass a 10 MB file upload limit on GitHub, you have to use Git Large File Storage (LFS) service. Git LFS replaces large files with text pointers inside Git, while storing the file contents on a remote server like GitHub.com or GitHub Enterprise.

您可以直接将GitHub存储库上传到Binder网站.GitHub存储库必须至少包含免费文件:带有代码的Jupyter笔记本,带有模型和权重的pickle文件以及用于创建python环境的requirements.txt文件。 要绕过GitHub上10 MB的文件上传限制,您必须使用Git大文件存储(LFS)服务。 Git LFS使用Git内部的文本指针替换大文件,同时将文件内容存储在GitHub.com或GitHub Enterprise等远程服务器上。

Image for post
Source: https://mybinder.org/
资料来源: https : //mybinder.org/

To build and launch your GitHub repository, you provide your repository name or URL and Jupyter notebook file name. If you want your app to execute without displaying the code, you can use voila by putting “/voila/render/” before the Jupyter notebook file name. Voila turns Jupyter notebooks into standalone web applications. It is crucial to change the dropdown menu from file to URL to be able to access the app on the internet. Don’t forget to copy the Binder URL for your app to share it with your friends. After that, you press the “Launch” button and wait.

要构建和启动GitHub存储库,请提供存储库名称或URL以及Jupyter笔记本文件名。 如果您希望您的应用程序,而不显示要执行的代码,你可以使用由Jupyter笔记本文件名前把“/瞧/渲染/”。 Voila将Jupyter笔记本变成了独立的Web应用程序。 将下拉菜单从文件更改为URL至关重要,以便能够在Internet上访问该应用程序。 不要忘记为您的应用程序复制活页夹URL,以便与您的朋友共享。 之后,您按下“启动”按钮并等待。

Unfortunately, since Binder has to build your environment, it may take up to ten minutes to launch your site. If the site is frequently used, the loading time is much shorter. The final version of my site looks like this:

不幸的是,由于Binder必须构建您的环境,因此可能最多需要十分钟才能启动您的网站。 如果该站点是经常使用的,则加载时间要短得多。 我网站的最终版本如下所示:

Conclusion: a combination of fastai, voila, and Binder enables creative individuals to code and deploy simple web applications with not much effort. The good is that Binder is easy and free to use. Not so good is that it takes a long time to launch your application on Binder. The fact that Binder cannot handle substantial file sizes (I could not load 81 MB pickle file) is also a significant negative. The best is that my wife was thrilled with this app and that what counts the most for me.

结论:fastai,voila和Binder的组合使富有创造力的个人可以轻松编写代码并部署简单的Web应用程序。 这样做的好处是,活页夹易于使用且免费。 不好的是,它需要很长时间才能在Binder上启动您的应用程序。 Binder无法处理大量文件(我无法加载81 MB的pickle文件)这一事实也是一个明显的负面影响。 最好的是,我的妻子对这个应用程序感到非常兴奋,这对我来说最重要。

Thank you for your time in reading this post.

感谢您抽出宝贵的时间阅读这篇文章。

Best wishes in these difficult times,

在这些困难的日子里表示最良好的祝愿,

Andrew@tampapath

安德鲁@tampapath

翻译自: https://medium.com/the-innovation/web-ai-app-for-gardeners-centipedes-vs-millipedes-6f61ff9156c6

cent ultraiso

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值