0
votes

I managed to convert my model to model.JSON and manage to load it using model.executeAsync(). Then how can i accessed the output to get label and confidence value in order to display it. model.executeAsync() just return me a bunch of array value

here is my index.js

async function init(){
try {
        model = await 
        tf.loadGraphModel('http://localhost/demo7/model/model.json');
    } catch (err) {
        console.log(err);
    }}

async function predict() {
    console.log("executing model");
    let user_pic = document.querySelector('img');
model.executeAsync(tf.browser.fromPixels(user_pic).cast('int32').expandDims())
console.log('This is your model: ', model, 'This is your prediction: ', prediction) }}
init()

result: sample result

[[PromiseResult]]: Array(7) 0: e dataId: {} dtype: "float32" id: 3350 isDisposedInternal: false kept: false rankType: "3" scopeId: 6152 shape: (3) [1, 300, 4] size: 1200 strides: (2) [1200, 4] isDisposed: (...) rank: (...) proto: Object 1: e dataId: {} dtype: "float32" id: 3372 isDisposedInternal: false kept: false rankType: "1" scopeId: 6193 shape: 1 size: 1 strides: [] isDisposed: (...) rank: (...) proto: Object 2: e dataId: {} dtype: "float32" id: 3367 isDisposedInternal: false kept: false rankType: "2" scopeId: 6182 shape: (2) [1, 300] size: 300 strides: [300] isDisposed: (...) rank: (...) proto: Object 3: e dataId: {} dtype: "float32" id: 2254 isDisposedInternal: false kept: false rankType: "3" scopeId: 3543 shape: (3) [1, 300, 8] size: 2400 strides: (2) [2400, 8] isDisposed: (...) rank: (...) proto: Object

1
Could you please add the relevant part of the code that is outputting what you have in the pictures ? By the way it is better to add code than images as people can copy what you have and try it on their own. - edkeveked
Hi, i already edit the question with sample code. It's my first time asking by the way so not very familiar how to include code etc. sorry - NewUser

1 Answers

0
votes

To get your prediction you need

const prediction = await model.executeAsync(tf.browser.fromPixels(user_pic).cast('int32').expandDims());