From 72f977a6393a703b457a26fdceed4aedc94af1a4 Mon Sep 17 00:00:00 2001 From: "Leomotors (Ubuntu)" <59821765+Leomotors@users.noreply.github.com> Date: Mon, 7 Mar 2022 16:47:41 +0700 Subject: [PATCH] Update Return Schema --- food-busters-ai/index.ts | 4 ++-- food-busters-ai/lib/index.ts | 37 ++++++++++++++++++------------------ food-busters-ai/lib/types.ts | 7 ++++++- package.json | 4 ++-- 4 files changed, 28 insertions(+), 24 deletions(-) diff --git a/food-busters-ai/index.ts b/food-busters-ai/index.ts index 40a069a..1b5a85d 100644 --- a/food-busters-ai/index.ts +++ b/food-busters-ai/index.ts @@ -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; diff --git a/food-busters-ai/lib/index.ts b/food-busters-ai/lib/index.ts index f862f74..b4ed9ba 100644 --- a/food-busters-ai/lib/index.ts +++ b/food-busters-ai/lib/index.ts @@ -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; diff --git a/food-busters-ai/lib/types.ts b/food-busters-ai/lib/types.ts index 7f6b9c2..9acaded 100644 --- a/food-busters-ai/lib/types.ts +++ b/food-busters-ai/lib/types.ts @@ -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; diff --git a/package.json b/package.json index 5303b3b..101d87d 100644 --- a/package.json +++ b/package.json @@ -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",