Giter VIP home page Giter VIP logo

bachelor10 / symbol-predictor-server Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 1.0 111.8 MB

This is part of a BS in computer engineering at NTNU, Trondheim. An example server implementation which classifies input from an end user and returns expressions in LaTeX. https://github.com/bachelor10/recurrent-octo-sniffle is the experimentation repository and https://github.com/bachelor10/PredictorClient is the front end library used.

License: MIT License

Python 82.89% HTML 4.04% JavaScript 8.77% CSS 4.30%
prediction classification keras tornado ntnu machine-learning

symbol-predictor-server's Introduction

symbol-predictor-server

This a server including a simple API to run prediction on mathematical symbols and expressions.

Prerequisites

  1. Python 3
  2. Pip (to your python 3 version)

Running the server

Do the following steps to run the server:

  1. Clone the repository (git clone ...)
  2. Install the dependencies (pip install -r /path/to/requirements.txt)
  3. Download the combined_model.
  4. Add the model to the folder /classification/
  5. Run the server (python /path/to/server.py)

Running the tests

To run the tests run the following command from the root directory:

python -m unittest discover test/

API

The server has a single endpoint, a POST handler the on /api endpoint

POST /api

Input

The endpoint expects data on the format application/JSON.

The request's body should be on the format:

Coordinates2D = {x: number, y: number}

Trace = Array<Coordinates2D>

{
    "buffer": "Array<Trace>"
}

Output

The output from the endpoint includes:

  1. The prediction converted to LaTeX.
  2. A list of all the symbols segmented from the traces.
  3. A list of the top ten probabilities for each segmented symbol

The response body will be on the format:

TraceGroup = Array<number> // List of indexes which combined creates a symbol (indexes from the "buffer" in input). 

Probability = number // Number between 0 and 1.
Probabilities = Array<Probability> // List of top 10 propabilities.

Label = string // A latex representation of a single symbol.
Labels = Array<Label> // List of top 10 labels (corresponds with Probabilities).

{
    "latex": string, // The full expression in latex
    "probabilities": {
        "tracegroup": Array<TraceGroup>, // trace indexes combined into symbols
        "labels": Array<Labels>, // The labels corresponding with each probability.
        "values": Array<Probabilities> // The probabilities with length equal to the number of predicted symbols
    }
}

Example

request = {
    "url": "/api",
    "method": "POST",
    "body": {
        buffer: [
            [
                {x: 0, y: 1},
                {x: 1, y: 2}
            ],
            [
                {x: 4, y: 8},
                {x: 5, y: 9}
            ]
        ]
    }
}

response = {
    "body": {
        "latex": "\sqrt{3}",
        "probabilities": {
            "tracegroup": [
                [0], 
                [1]
            ],
            "labels": [
                ["\sqrt", "\alpha", "y", ...], 
                ["3", "9", "\beta", ...]
            ],
            "values": [
                [0.7, 0.2, 0.05, ...], 
                [0.9, 0.03, 0.01, ...]
            ]
        }
    }
}

symbol-predictor-server's People

Contributors

evedal avatar torkilso avatar havlan avatar

Stargazers

DCK_WS avatar

Watchers

James Cloos avatar  avatar

Forkers

torkilso

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.