I am running a prediction on a tensorflow-serving model, and I get back this PredictResponse
object as output:
Result:
outputs {
key: "outputs"
value {
dtype: DT_FLOAT
tensor_shape {
dim {
size: 1
}
dim {
size: 20
}
}
float_val: 0.000343723397236
float_val: 0.999655127525
float_val: 3.96821117632e-11
float_val: 1.20521548297e-09
float_val: 2.09611101809e-08
float_val: 1.46216549979e-09
float_val: 3.87274603497e-08
float_val: 1.83520256769e-08
float_val: 1.47733780764e-08
float_val: 8.00914179422e-08
float_val: 2.29388191997e-07
float_val: 6.27798826258e-08
float_val: 1.08802950649e-07
float_val: 4.39628813353e-08
float_val: 7.87182985462e-10
float_val: 1.31638898893e-07
float_val: 1.42612295306e-08
float_val: 3.0768305237e-07
float_val: 1.12661648899e-08
float_val: 1.68554503688e-08
}
}
I would like to get the out the float vals as a list. Or, alternatively, return the value/index of the argmax float_val!
This is generated by:
stub = prediction_service_pb2.beta_create_PredictionService_stub(channel) result = stub.Predict(request, 200.0)
Thanks for your help in advance.
There are different methods available to convert taken input to a float value. Following methods can be used for this purpose: The Single.Parse () method is used to convert given string value to the float value.
You can use the return value from the Promise object ONLY in a async function. You should do all the stuff that you'd like to do with the return result in a printAddress () async function.
Let's see how we can access returned data. It is the most simple and the most obvious way. Here we (1) fetch data from the API, (2) transform it into JSON object and then (3) print user's address value to the console.
I'd say that the only way to get this JSON object outside the fetch () call is to assign it to a variable. If you could provide your piece a code it would be easier to understand and to help:)
The answer is:
floats = result.outputs['outputs'].float_val
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With