Giter Club home page Giter Club logo

reseepe's Introduction

Reseepe

Final project of AI class. A platform who can recognize the dishes and show the heat.

About YOLO

A single convolutional network simultaneously predicts multiple bounding boxes and class probabilities for those boxes. YOLO trains on full images and directly optimizes detection performance.

  • YOLO is extremely fast. We simply run our neural network on a new image at test time to predict detections.

  • YOLO reasons globally about the image when making predictions.

  • YOLO learns generalizable representations of objects.

Running by terminal

npm run test

Libraries

<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.0.0/p5.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.9.0/addons/p5.dom.min.js"></script>
<script src="https://unpkg.com/[email protected]/dist/ml5.min.js"></script>
<script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>

Importing database

let fruit = new Array(
    "apple",
    "banana",
    "cherry",
    "grape",
    "kiwi",
    "orange",
    "peach",
    "pear",
    "plum",
    "pineapple",
    "strawberry",
    "broccoli",
    "carrot",
    "cucumber",
    "cabbage",
    "lettuce",
    "tomato",
    "potato"
);
let calo = new Array(
    52,
    87,
    5,
    3,
    2,
    45,
    42,
    96,
    30,
    96,
    38,
    45,
    30,
    14,
    26,
    10,
    25,
    110
);

Detection and recognition

function imageReady() {
    yolo.detect(upimg, gotResult);
}

Getting results

{
    "label": "apple",
    "confidence": 0.9158242344856262,
    "h": 0.24185683177067682,
    "w": 0.24617767333984375,
    "x": 0.7303961240328275,
    "y": 0.5583128195542556
}

Searching and counting

let name = new Array(); //Build an array of all detected labels
let num = new Array(); //Add counters for each labels
let q = 0;

for (let i = 0; i < objects.length; i++) {
    //The first one is always special
    if (i == 0) {
        name[q] = objects[i].label;
        num[q] = 1;
    }
    //Comparing the label with previous one
    //A new label
    else if (i > 0 && objects[i].label != objects[i - 1].label) {
        q++;
        name[q] = objects[i].label;
        num[q] = 1;
    }
    //An existing label
    else if (i > 0 && objects[i].label == objects[i - 1].label) {
        num[q]++;
    }
}

Searching heat data from the database

for (h = 0; h <= fruit.length; h++) {
    if (name[i] == fruit[h]) {
        sum = sum + calo[h] * num[i].toFixed(1); //The total heat
        document.getElementById("heat").innerHTML =
            document.getElementById("heat").innerHTML +
            calo[h].toFixed(1) +
            " ร— " +
            num[i] +
            " cal<br>";
    }
}

reseepe's People

Contributors

zixuan96 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.