Skip to content
This repository has been archived by the owner on Apr 21, 2022. It is now read-only.

Commit

Permalink
Update Return Schema
Browse files Browse the repository at this point in the history
  • Loading branch information
leomotors committed Mar 7, 2022
1 parent 3a17444 commit 72f977a
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 24 deletions.
4 changes: 2 additions & 2 deletions food-busters-ai/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import {
VersionRejectReason,
} from "./lib";

const MinAppVersion = 306;
const MinWebVersion = 4;
const MinAppVersion = 321;
const MinWebVersion = 6;

const index: AzureFunction = async (context: Context, req: HttpRequest) => {
const { body, headers } = req;
Expand Down
37 changes: 18 additions & 19 deletions food-busters-ai/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,26 @@ import * as tf from "@tensorflow/tfjs-node";

import { Version } from "../../config";

import { MLResult, FoodNutrition } from "./types";

const labelMap: { [key: number]: { name: string; nutrition: FoodNutrition } } =
{
1: {
name: "Omelet Rice",
nutrition: {
carbohydrate: 65,
fat: 15,
protein: 20,
},
import { MLResult, FoodNutrition, Label } from "./types";

const labelMap: { [key: number]: { name: Label; nutrition: FoodNutrition } } = {
1: {
name: { en: "Omelet Rice", th: "ข้าวไข่เจียว" },
nutrition: {
carbohydrate: 65,
fat: 15,
protein: 20,
},
2: {
name: "Chicken Rice",
nutrition: {
carbohydrate: 45,
fat: 25,
protein: 30,
},
},
2: {
name: { en: "Chicken Rice", th: "ข้าวมันไก่" },
nutrition: {
carbohydrate: 45,
fat: 25,
protein: 30,
},
};
},
};

// const mroot = "food-busters-ai/model";
let net: tf.GraphModel;
Expand Down
7 changes: 6 additions & 1 deletion food-busters-ai/lib/types.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
export interface MLResult {
foodName: string;
foodName: Label;
foodNutrition: FoodNutrition;
confidence: number;
version: string;
}

export interface Label {
en: string;
th?: string;
}

export interface FoodNutrition {
carbohydrate: number;
fat: number;
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"name": "food-busters-azure-functions",
"version": "1.0.15",
"version": "1.0.16",
"description": "Food Buster's Azure Functions",
"repository": "https://github.com/Food-Busters/azure-functions",
"author": "Leomotors",
"license": "MIT",
"scripts": {
"build": "yarn lm-config config.ts && tsc",
"build": "yarn lm-inc && yarn lm-config config.ts && tsc",
"watch": "tsc -w",
"prestart": "npm run build",
"start": "func start",
Expand Down

0 comments on commit 72f977a

Please sign in to comment.