Fast.ai Camera App for CNNs

栏目: IT技术 · 发布时间: 6年前

内容简介:This is a web app that allows a user to take a picture using an interface similar to a native camera app. After the picture is taken, it's sent to a fast.ai CNN model running onThere are a handful of prebuilt apps that allow a user to upload a photo (I'd l

Fast.ai CNN Camera App

Overview

This is a web app that allows a user to take a picture using an interface similar to a native camera app. After the picture is taken, it's sent to a fast.ai CNN model running on render . The modified server will the return a classification of the image along with related content.

There are a handful of prebuilt apps that allow a user to upload a photo ( this and this ), but I couldn't find an app that allowed the user to skip the step of manually uploading it.

I'd like to give a major shoutout to @abenjamin765 whose tutorial/repo was instrumental in creating this application.

Demo

Check out a demo app here . The demo app recognizes everyday objects (cars, people, trees, computers, chairs, etc).

Getting Started

To get started, fork this repo. A few things you'll need to change:

  1. In scripts.js , change const url = "https://dc2.onrender.com/analyze" to the url for your render endpoint.
  2. In index.hmtl , you may want to modify the starting app description (in <p id="content"> ), the header ( <h1 id="type"> ), and the title <title> .
  3. Follow this guide to set up your render server if you haven't already.
  4. In server.py in your render repo, change this line return JSONResponse({'result': str(prediction)}) to something like this. You can take a look at the server code for the demo project here .
# change the prediction into a string and capitalize it
# to map it to items to grab the description
prediction = str(prediction).capitalize()	
# Items contains the description text for each result
items = {	
    'Tree': 'Trees are great!', 	
    'Person': 'If you are reading this, you too are a person', 	
    'Car': '4 wheels is all you need',	
    'Computer': 'A very useful tool',	
    'Pen': 'Useful for writing something down!',	
    'Desk': 'The perfect place to put your things',	
    'Chair': 'Ideal for sitting'	
}	
return JSONResponse({	
    'result': prediction,	
    'content': items[prediction]	
})

Hosting

Github Pages

The easiest solution is github pages ; however, your repo must either be public or you'll need a paid github plan. Within the repo go to settings and search for github pages to get started.

Netlify

Netlify is free and is only more marginally tedious to set up, and has a lot of great features that github pages doesn't have.

In the pipeline

I'm hoping to add support for flask and create a template server you can use if you'd prefer to use the app without render. Additionally, I'd like to make the content area within the app scrollable. If you'd like to contribute, just submit a PR!


以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

网络、群体与市场

网络、群体与市场

大卫·伊斯利(David Esley)、乔恩·克莱因伯格(Jon Kleinberg) / 李晓明、王卫红、杨韫利 / 清华大学出版社 / 2011-10-1 / CNY 69.00

过去十年来,现代社会中复杂的连通性向公众展现出与日俱增的魅力。这种连通性在许多方面都有体现并发挥着强大的作用,包括互联网的快速成长、全球通信的便捷,以及新闻与信息(及传染病与金融危机)以惊人的速度与强度传播的能力。这种现象涉及网络、动机和人们的聚合行为。网络将人们的行为联系起来,使得每个人的决定可能对他人产生微妙的后果。 本书是本科生的入门教材,同时也适合希望进入相关领域的高层次读者。它从交......一起来看看 《网络、群体与市场》 这本书的介绍吧!

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

随机密码生成器
随机密码生成器

多种字符组合密码

XML 在线格式化
XML 在线格式化

在线 XML 格式化压缩工具